【发布时间】:2019-09-23 08:25:57
【问题描述】:
我正在尝试免费托管我的 discord.py 机器人,我听说 Heroku 是一个不错的选择。我的测功机工作正常,并且已打开,但是当我部署时,我的机器人没有上线。我没有错误,它说它已部署,但我的机器人从未上线。
我已尝试重新生成机器人令牌,并将其放入我的 Heroku 应用程序中,但仍然无法正常工作。
import discord
from discord.ext import commands
from discord.ext.commands import bot
import asyncio
import requests
import os
description = '''EchoBot by EchoNoahGaming'''
bot = commands.Bot(command_prefix='-', description=description)
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.command()
async def announcement(ctx, *, args):
"""Announcement command!"""
embed=discord.Embed(title="Announcement", description=args, color=0x7700aa)
embed.set_footer(text="By EchoNoahGaming")
await ctx.send("@everyone", embed=embed)
client.run(str(os.environ.get('BOT_TOKEN')))
这是机器人代码。
我预计机器人会上线,因为没有错误,但它没有,并且一直处于离线状态。
Procfile 代码是
worker: python3 bot.py
requirements.txt 内容为
discord
asyncio
如果你还需要什么,请告诉我。 GitHub 链接是 https://github.com/EchoNoahGaming/echobot/blob/master/,但我会在此处发布任何文件,这样更容易。
【问题讨论】:
-
您好,您是否已将
BOT_TOKEN环境变量添加到 Heroku 设置中的“config var”中? -
是的,我做到了。我尝试更改它并重新生成我的机器人令牌,但它不起作用。
-
嗯...
from discord.ext.commands import bot。我以前从未见过这样的台词。 (尝试删除它?)如果您安装了heroku cli,还可以尝试调用日志以查找回溯/错误heroku logs -a <your-app-name>,这比尝试猜测错误要好。 -
我认为它用于获取 discord.py,但我会尝试。编辑:它没有工作。
-
成功了,谢谢!我真的很高兴,因为现在我可以托管我的东西了。再次感谢!
标签: python discord discord.py discord.py-rewrite