Heroku Discord Bot部署时离线?



我目前正在使用Python创建一个Discord bot -特别是通过JetBrains的PyCharms IDE。我使用PyCharm作为IDE的问题是没有Heroku的集成,使用控制台命令w/Github是所有噩梦中的噩梦。

我在github上发布了我的代码,应用程序通过Heroku成功部署,但应用程序离线。我到处都检查过了,没有一个解决方案适合我。

以下是我的文件和它们当前的内容:

main.py

import discord
from urllib.request import urlopen
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
token = "***********************"
client = discord.Client()
URL = "https://www.surrenderat20.net/search/label/PBE/"
page = urlopen(URL)
soup = BeautifulSoup(page, 'html.parser')
pbe_titles = soup.find_all('h1', attrs={'class': 'news-title'})
links = []
for tag in pbe_titles:
for anchor in tag.find_all('a'):
links.append(tag.text.strip())
links.append(anchor['href'])
output = 'n'.join(str(line) for line in links[:2])
print(output)

@bot.command(name='pbe')
async def peebeeee(ctx):
response = output
await ctx.send(response)
bot.run(token)

我正在关闭我的Token代码。如果我有兴趣分享代码,我会创建一个。env,但是。env在Pycharm中似乎不太好用。

Procfile:worker: python bot/main.py让:discord.pyRuntime.txt:python-3.8.7

我当前的github的结构是这样的,列出的所有文件都在主页上,包括文件夹:bot,其中包含main.py **我有Git列为私有atm

如果有人可以照亮为什么我的不和机器人不会保持在线,即使Heroku成功部署它,那将是伟大的。谢谢你。

Thisrepo可能会有所帮助,因为它提供了一些关于创建机器人并在Heroku上托管它的见解。

我能想到你可能没有做的唯一一件事就是你没有打开worker:

在"资源"下,执行以下操作:点击"铅笔"图标。把工人从关到开。点击"确认"以完成决定。

最新更新