Discord.py重写bot在heroku中不起作用,但在本地起作用

时间:2019-02-16 11:07:48

标签: python heroku discord.py-rewrite

该机器人在本地运行,但在Heroku中托管时无法正常工作。

这是Heroku的日志文件

heroku logs --tail
2019-02-14T08:47:54.816954+00:00 heroku[worker.1]: Starting process with  command `python bot.py`
2019-02-14T08:47:55.393447+00:00 heroku[worker.1]: State changed from starting to up
2019-02-14T08:48:01.249027+00:00 app[worker.1]: We have logged in as Sheogorath#1014
2019-02-15T09:05:48.819190+00:00 heroku[worker.1]: Cycling
2019-02-15T09:05:48.894223+00:00 heroku[worker.1]: State changed from up to starting
2019-02-15T09:05:49.936542+00:00 heroku[worker.1]: Stopping all processes with SIGTERM
2019-02-15T09:05:50.060234+00:00 heroku[worker.1]: Process exited with status 143
2019-02-15T09:05:53.405715+00:00 heroku[worker.1]: Starting process with command `python bot.py`
2019-02-15T09:05:54.392209+00:00 heroku[worker.1]: State changed from starting to up
2019-02-15T09:06:01.127733+00:00 app[worker.1]: We have logged in as Sheogorath#1014
2019-02-16T09:33:52.034802+00:00 app[worker.1]: bot-testing: LordDraagon#7410: LordDraagon: hello uncle sheo
2019-02-16T09:33:52.034995+00:00 app[worker.1]: Ignoring exception in on_message
2019-02-16T09:33:52.042092+00:00 app[worker.1]: Traceback (most recent call last):
2019-02-16T09:33:52.042231+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/discord/client.py", line 307, in _run_event
2019-02-16T09:33:52.042234+00:00 app[worker.1]: yield from getattr(self, event)(*args, **kwargs)
2019-02-16T09:33:52.042299+00:00 app[worker.1]: File "bot.py", line 75, in on_message
2019-02-16T09:33:52.042302+00:00 app[worker.1]: await replyBack(message)
2019-02-16T09:33:52.042366+00:00 app[worker.1]: File "bot.py", line 19, in replyBack
2019-02-16T09:33:52.042368+00:00 app[worker.1]: await message.channel.send('Greetings! Salutations! Welcome! Now go away. Leave. Run. Or die.')
2019-02-16T09:33:52.042450+00:00 app[worker.1]: AttributeError: 'Channel' object has no attribute 'send'
2019-02-16T09:33:59.644154+00:00 app[worker.1]: bot-testing: LordDraagon#7410: LordDraagon: sheogorath.member_count()
2019-02-16T09:33:59.647064+00:00 app[worker.1]: Ignoring exception in on_message
2019-02-16T09:33:59.647834+00:00 app[worker.1]: Traceback (most recent call last):
2019-02-16T09:33:59.648005+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/discord/client.py", line 307, in _run_event
2019-02-16T09:33:59.648008+00:00 app[worker.1]: yield from getattr(self, event)(*args, **kwargs)
2019-02-16T09:33:59.648147+00:00 app[worker.1]: File "bot.py", line 82, in on_message
2019-02-16T09:33:59.648149+00:00 app[worker.1]: await getDetails(message,message.guild)
2019-02-16T09:33:59.648339+00:00 app[worker.1]: AttributeError: 'Message' object has no attribute 'guild'
2019-02-16T09:38:43.636447+00:00 app[api]: Starting process with command `heroku run` by user buddhiadikari@live.com
2019-02-16T09:38:47.076943+00:00 heroku[run.2120]: State changed from starting to up
2019-02-16T09:38:46.941395+00:00 heroku[run.2120]: Awaiting client
2019-02-16T09:38:47.234998+00:00 heroku[run.2120]: Starting process with command `heroku run`
2019-02-16T09:38:51.406757+00:00 heroku[run.2120]: State changed from up to complete
2019-02-16T09:38:51.387399+00:00 heroku[run.2120]: Process exited with status 127
2019-02-16T09:40:47.905773+00:00 heroku[worker.1]: Cycling
2019-02-16T09:40:47.986939+00:00 heroku[worker.1]: State changed from up to starting
2019-02-16T09:40:49.543819+00:00 heroku[worker.1]: Stopping all processes with SIGTERM
2019-02-16T09:40:49.752067+00:00 heroku[worker.1]: Process exited with status 143
2019-02-16T09:40:51.106330+00:00 heroku[worker.1]: Starting process with command `python bot.py`
2019-02-16T09:40:51.679966+00:00 heroku[worker.1]: State changed from starting to up
2019-02-16T09:40:55.966779+00:00 app[worker.1]: We have logged in as Sheogorath#1014
2019-02-16T09:54:18.362670+00:00 app[api]: Starting process with command `pip` by user buddhiadikari@live.com
2019-02-16T09:54:23.024305+00:00 heroku[run.9771]: State changed from starting to up
2019-02-16T09:54:23.004772+00:00 heroku[run.9771]: Awaiting client
2019-02-16T09:54:23.306227+00:00 heroku[run.9771]: Starting process with command `pip`
2019-02-16T09:54:28.935863+00:00 heroku[run.9771]: Process exited with status 0
2019-02-16T09:54:29.145616+00:00 heroku[run.9771]: State changed from up to complete
2019-02-16T09:57:21.693571+00:00 app[api]: Starting process with command `python3 -m pip install -U https://github.com/Rapptz/discord.py/archive/master.zip#egg=discord.py[voice]` by user buddhiadikari@live.com
2019-02-16T09:57:25.243366+00:00 heroku[run.4339]: Awaiting client
2019-02-16T09:57:25.560838+00:00 heroku[run.4339]: Starting process with command `python3 -m pip install -U https://github.com/Rapptz/discord.py/archive/master.zip#egg=discord.py[voice]`
2019-02-16T09:57:26.294896+00:00 heroku[run.4339]: State changed from starting to up
 2019-02-16T09:57:49.117673+00:00 heroku[run.4339]: State changed from up to complete
2019-02-16T09:57:49.098072+00:00 heroku[run.4339]: Process exited with status 1
2019-02-16T10:00:29.850598+00:00 app[api]: Starting process with command `pip install --upgrade pip` by user buddhiadikari@live.com
2019-02-16T10:00:33.959344+00:00 heroku[run.7180]: State changed from starting to up
2019-02-16T10:00:33.977943+00:00 heroku[run.7180]: Awaiting client
2019-02-16T10:00:34.331603+00:00 heroku[run.7180]: Starting process with command `pip install --upgrade pip`
2019-02-16T10:00:42.879420+00:00 heroku[run.7180]: State changed from up to complete
2019-02-16T10:00:42.858327+00:00 heroku[run.7180]: Process exited with status 0
2019-02-16T10:02:30.329208+00:00 app[api]: Starting process with command `python3 -m pip install -U https://github.com/Rapptz/discord.py/archive/master.zip#egg=discord.py[voice]` by user buddhiadikari@live.com
2019-02-16T10:02:35.025887+00:00 heroku[run.3241]: State changed from starting to up
2019-02-16T10:02:34.960600+00:00 heroku[run.3241]: Awaiting client
2019-02-16T10:02:35.273280+00:00 heroku[run.3241]: Starting process with command `python3 -m pip install -U https://github.com/Rapptz/discord.py/archive/master.zip#egg=discord.py[voice]`
2019-02-16T10:03:14.623433+00:00 heroku[run.3241]: Process exited with status 1
2019-02-16T10:03:15.107022+00:00 heroku[run.3241]: State changed from up to complete
2019-02-16T10:04:01.365397+00:00 app[api]: Starting process with command `python3 -m pip install -U discord.py` by user buddhiadikari@live.com
2019-02-16T10:04:04.717198+00:00 heroku[run.4162]: Awaiting client
2019-02-16T10:04:05.009961+00:00 heroku[run.4162]: Starting process with command `python3 -m pip install -U discord.py`
2019-02-16T10:04:05.498337+00:00 heroku[run.4162]: State changed from starting to up
2019-02-16T10:04:12.417782+00:00 heroku[run.4162]: Process exited with status 0
2019-02-16T10:04:13.653844+00:00 heroku[run.4162]: State changed from up to complete
2019-02-16T10:04:45.918379+00:00 app[api]: Starting process with command `python3 -m pip install -U https://github.com/Rapptz/discord.py/archive/master.zip#egg=discord.py[voice]` by user buddhiadikari@live.com
2019-02-16T10:04:50.380315+00:00 heroku[run.4892]: Awaiting client
2019-02-16T10:04:50.657792+00:00 heroku[run.4892]: State changed from starting to up
2019-02-16T10:04:50.696282+00:00 heroku[run.4892]: Starting process with command `python3 -m pip install -U https://github.com/Rapptz/discord.py/archive/master.zip#egg=discord.py[voice]`
2019-02-16T10:05:09.548908+00:00 heroku[run.4892]: State changed from up to complete
2019-02-16T10:05:09.531050+00:00 heroku[run.4892]: Process exited with status 1
2019-02-16T10:05:23.172659+00:00 app[worker.1]: bot-testing: LordDraagon#7410: LordDraagon: sheogorath.member_count()
2019-02-16T10:05:23.172801+00:00 app[worker.1]: Ignoring exception in on_message
2019-02-16T10:05:23.176751+00:00 app[worker.1]: Traceback (most recent call last):
2019-02-16T10:05:23.176842+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/discord/client.py", line 307, in _run_event
2019-02-16T10:05:23.176845+00:00 app[worker.1]: yield from getattr(self, event)(*args, **kwargs)
2019-02-16T10:05:23.176901+00:00 app[worker.1]: File "bot.py", line 82, in on_message
2019-02-16T10:05:23.176903+00:00 app[worker.1]: await getDetails(message,message.guild)
2019-02-16T10:05:23.176969+00:00 app[worker.1]: AttributeError: 'Message' object has no attribute 'guild'
2019-02-16T10:10:15.048230+00:00 app[api]: Scaled to worker@0:Free by user buddhiadikari@live.com
2019-02-16T10:10:15.359585+00:00 heroku[worker.1]: State changed from up to down
2019-02-16T10:10:16.387560+00:00 heroku[worker.1]: Stopping all processes with SIGTERM
2019-02-16T10:10:16.481690+00:00 heroku[worker.1]: Process exited with status 143
2019-02-16T10:16:04.912170+00:00 app[api]: Starting process with command `python3 -m pip install -U https://github.com/Rapptz/discord.py/archive/rewrite.zip` by user buddhiadikari@live.com
2019-02-16T10:16:08.855491+00:00 heroku[run.9325]: State changed from starting to up
2019-02-16T10:16:08.841552+00:00 heroku[run.9325]: Awaiting client
2019-02-16T10:16:09.148281+00:00 heroku[run.9325]: Starting process with command `python3 -m pip install -U https://github.com/Rapptz/discord.py/archive/rewrite.zip`
2019-02-16T10:16:27.380488+00:00 heroku[run.9325]: State changed from up to complete
2019-02-16T10:16:27.365861+00:00 heroku[run.9325]: Process exited with status 0
2019-02-16T10:19:50.688221+00:00 app[api]: Scaled to worker@1:Free by user buddhiadikari@live.com
2019-02-16T10:19:55.511089+00:00 heroku[worker.1]: Starting process with command `python bot.py`
2019-02-16T10:19:56.172891+00:00 heroku[worker.1]: State changed from starting to up
2019-02-16T10:20:02.222063+00:00 app[worker.1]: We have logged in as Sheogorath#1014
2019-02-16T10:20:21.514609+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=sheogorath-bot.herokuapp.com request_id=97c7acd9-af88-4bdf-b367-6274f91a6aeb fwd="112.135.12.166" dyno= connect= service= status=503 bytes= protocol=https
2019-02-16T10:20:58.490018+00:00 app[worker.1]: bot-testing: LordDraagon#7410: LordDraagon: hello uncle sheo
2019-02-16T10:20:58.490490+00:00 app[worker.1]: Ignoring exception in on_message
2019-02-16T10:20:58.492711+00:00 app[worker.1]: Traceback (most recent call last):
2019-02-16T10:20:58.492816+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/discord/client.py", line 307, in _run_event
2019-02-16T10:20:58.492818+00:00 app[worker.1]: yield from getattr(self, event)(*args, **kwargs)
2019-02-16T10:20:58.492855+00:00 app[worker.1]: File "bot.py", line 75, in on_message
2019-02-16T10:20:58.492857+00:00 app[worker.1]: await replyBack(message)
2019-02-16T10:20:58.492892+00:00 app[worker.1]: File "bot.py", line 19, in replyBack
2019-02-16T10:20:58.492895+00:00 app[worker.1]: await message.channel.send('Greetings! Salutations! Welcome! Now go away. Leave. Run. Or die.')
2019-02-16T10:20:58.492977+00:00 app[worker.1]: AttributeError: 'Channel' object has no attribute 'send'
2019-02-16T10:21:08.406843+00:00 app[worker.1]: bot-testing: LordDraagon#7410: LordDraagon: sheogorath.member_count()
2019-02-16T10:21:08.408965+00:00 app[worker.1]: Ignoring exception in on_message
2019-02-16T10:21:08.409831+00:00 app[worker.1]: Traceback (most recent call last):
2019-02-16T10:21:08.409892+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/discord/client.py", line 307, in _run_event
2019-02-16T10:21:08.409895+00:00 app[worker.1]: yield from getattr(self, event)(*args, **kwargs)
2019-02-16T10:21:08.409971+00:00 app[worker.1]: File "bot.py", line 82, in on_message
2019-02-16T10:21:08.409974+00:00 app[worker.1]: await getDetails(message,message.guild)
2019-02-16T10:21:08.410030+00:00 app[worker.1]: AttributeError: 'Message' object has no attribute 'guild'

我有我的requirments.txt文件,其中包括这些依赖项。

  

git + https://github.com/Rapptz/discord.py@rewrite#egg=discord.py

     

重试

     

asyncio

我在我的procfile中有这个

  

工作者:python bot.py

据我所知,我认为Heroku无法为我的项目安装不一致的重写版本。我对使用Heroku的知识较少,但我希望我已经正确集成了Heroku

2 个答案:

答案 0 :(得分:0)

在requirements.txt中,删除所有内容并编写

git+https://github.com/Rapptz/discord.py@rewrite
dnspython==1.16.0
PyNaCl==1.3.0

下载重写分支。我真的不知道是否是因为在错误的heroku上使用了异步分支,但尝试这样做可能会有所帮助。

答案 1 :(得分:0)

错误为 AttributeError: Ignoring exception in on_message'Channel' object has no attribute 'send'AttributeError: 'Message' object has no attribute 'guild'

接下来您应该修复您的 requirements.txt。我使用了 Heroku,代码很完美,没有错误,但无法运行。为什么?因为 requirements.txt 中的 pip freeze > requirements.txt 根本不起作用。并且你不给代码或者代码的url,那我们怎么调试呢?