Reputation: 19
After i rewritten my extension loading code in discord.py 2.0 everything works fine except if i got any errors in a command it will not send me a error. i have to figure it out with prints this is very annoying tho. Is there a way to get the errors shown again, I got no error event or listeners
client = commands.Bot(command_prefix="!", intents=discord.Intents().all())
client.remove_command('help')
async def load_extensions():
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
await client.load_extension(f"cogs.{filename[:-3]}")
async def main():
async with client:
await load_extensions()
await client.start(tokn)
asyncio.run(main())
So after i deleted all cogs and nothing was loaded i still got no errors on anything, I also replaced the main function with client.run(token) itl run the bot but the cogs wont load but i get errors on command tho. anyone knows a fix?
Upvotes: 1
Views: 2448
Reputation: 5651
The default behaviour was changed to use the logging
framework instead.
Docs example & explanation: https://discordpy.readthedocs.io/en/latest/logging.html
Seeing as you're not using Client.run()
, but rather Client.start()
, there's no default handler being provided, so you have to do it yourself.
After following the example in the docs page linked above, your errors should get logged in a file named discord.log
(or however you decided to name it).
If you'd like it to output to stdout
(or stderr
) like before, either do that manually in on_command_error()
, or configure stderr
as your handler for the logger instead of the RotatingFileHandler
. This answer explains how to do that: https://stackoverflow.com/a/14058475/13568999
Upvotes: 1