It used to work fine so far both in heroku and locally. Now it only works locally but doesn't work aftter deploying on heroku. This is the log from Heroku:
2021-05-11T14:24:06.000000+00:00 app[api]: Build succeeded
2021-05-11T14:24:06.163275+00:00 heroku[worker.1]: State changed from starting to up
2021-05-11T14:24:15.306244+00:00 app[worker.1]: Traceback (most recent call last):
2021-05-11T14:24:15.306768+00:00 app[worker.1]: File "/app/dbot.py", line 2, in <module>
2021-05-11T14:24:15.307297+00:00 app[worker.1]: import discord
2021-05-11T14:24:15.307369+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/discord/__init__.py", line 23, in <module>
2021-05-11T14:24:15.307970+00:00 app[worker.1]: from .client import *
2021-05-11T14:24:15.307996+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/discord/client.py", line 36, in <module>
2021-05-11T14:24:15.308464+00:00 app[worker.1]: from .user import User
2021-05-11T14:24:15.308533+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/discord/user.py", line 26, in <module>
2021-05-11T14:24:15.309148+00:00 app[worker.1]: import discord.abc
2021-05-11T14:24:15.309214+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/discord/abc.py", line 101, in <module>
2021-05-11T14:24:15.309876+00:00 app[worker.1]: SnowflakeTime = Union[Snowflake, datetime]
2021-05-11T14:24:15.310045+00:00 app[worker.1]: NameError: name 'datetime' is not defined
2021-05-11T14:24:15.685219+00:00 heroku[worker.1]: Process exited with status 1
2021-05-11T14:24:15.995755+00:00 heroku[worker.1]: State changed from up to crashed
I have my requirments.txt file with these dependencies included:
git+https://github.com/Rapptz/discord.py
youtube_dl==2020.03.08
pynacl == 1.3.0
colorlog == 4.1.0
And I have this in my procfile:
worker: python dbot.py
I know that it says 'datetime' is not defined but here is the first few lines from my main python file:
import datetime
import discord
from discord.ext import commands
from discord import FFmpegPCMAudio
import random
import youtube_dl
import os
from discord.utils import get
import ctypes
import ctypes.util
As for my knowledge, it all started after i added the following event to my codes:
@client.event
async def on_message(ctx):
try:
if ctx.channel.name == "memes" and "https://" not in str(ctx.content) and not ctx.attachments:
await ctx.channel.purge(limit=1)
else:
await client.process_commands(ctx)
except:
await client.process_commands(ctx)
git+https://github.com/Rapptz/discord.py
is the development branch of discord.py, do not use it in production.
git+https://github.com/Rapptz/[email protected]
1.7.2 is the latest version.
Or from PyPi
discord.py>=1.7.2
discord.py is available in PyPI, and hence can be directly downloaded from PyPI.