Search code examples
discord.pypython-3.8argskeyword-argument

Print error code doesn't work (PyCharm, Python 3.8)


I found this code in Stackoverflow which prints any error messages. But it doesn't print the error. Just to say if it is relevant, PyCharm said that Bot doesn't have attribute AppInfo.

Code:

@bot.event
async def on_error(event, *args, **kwargs):
    embed = discord.Embed(title=':x: Event Error', colour=0xe74c3c)
    embed.add_field(name='Event', value=event)
    embed.description = '```py\n%s\n```' % traceback.format_exc()
    embed.timestamp = datetime.datetime.utcnow()
    await bot.AppInfo.owner.send(embed=embed)

Solution

  • I found another Stackoverflow question (Discord.py-Rewrite Sending an Error message when there is an unknown command or other error) which has the answer. As it seems, there was no need to complicate the command as the case with my code.