add error catch

This commit is contained in:
2021-11-20 20:04:00 +01:00
parent 46c168391b
commit 3434c0171e

10
main.py
View File

@@ -45,6 +45,14 @@ async def on_message(message):
if message.content.startswith(BOTDATA['prefix'] + 'hello'):
await message.channel.send("Hello, {}!".format(message.author))
@client.event
async def on_error(event, *args, **kwargs):
with open('err.log', 'a') as f:
if event == 'on_message':
f.write(f'Unhandled message: {args[0]}\n')
else:
raise
#keep_alive()
client.run(BOTDATA['token'])