【发布时间】:2021-08-05 14:08:39
【问题描述】:
我使用 Python 制作了一个 Discord Bot,并使用内置的 Git 命令将其托管在 Heroku 上。它运行主脚本,即 DiscordBot.py,该脚本从 topGainer.py 调用另一个 fn topGainer
当我在我的系统上本地运行 DiscordBot.py 时,机器人功能完美,但在 Heroku 上它无法调用 topGainer .py 函数 topGainer 返回一个使用 Tabulate 制作的列表
这是不和谐机器人的代码
if message.author == client.user:
return
if message.content.startswith('$gainer'):
tg=topGainer()
await message.channel.send(tg)
if message.content.startswith('$loser'):
tl=topLoser()
await message.channel.send(tl)
if message.content.startswith('$get'):
scrip = msg.split("$get ",1)[1]
info=basic(scrip)
await message.channel.send(info)
if message.content.startswith('$AnotherFunction'):
await message.channel.send('Coming Soon :')
我在 Heroku Procfile 中也有 worker: python DiscordBot.py
在 heroku 上,此代码确实登录了 discord 机器人,并且函数 $AnotherFunction 有效。
【问题讨论】:
-
您的意思是“无法从其他 python 文件调用函数”吗?
标签: python heroku discord discord.py