discord.py on_message_delete TypeError: on_message_delete() missing 1 required positional argument: 'message'
Question:
This command not work, error: TypeError: on_message_delete() missing 1 required positional argument: ‘message’
@client.event
async def on_message_delete(ctx,message):
with open('log.json', 'r', encoding='utf-8') as f:
guilds_dict = json.load(f)
embed = discord.Embed(title=f"deleted a message {message}",description="", color=0xFF0000)
embed.add_field(name=message.content, value=f"This is the message that he has deleted",inline=True)
channel_id = guilds_dict[str(ctx.guild.id)]
await client.get_channel(int(channel_id)).send(embed=embed)```
Answers:
There is no context (ctx
) in an event. Remove the ctx, and it will work.
This command not work, error: TypeError: on_message_delete() missing 1 required positional argument: ‘message’
@client.event
async def on_message_delete(ctx,message):
with open('log.json', 'r', encoding='utf-8') as f:
guilds_dict = json.load(f)
embed = discord.Embed(title=f"deleted a message {message}",description="", color=0xFF0000)
embed.add_field(name=message.content, value=f"This is the message that he has deleted",inline=True)
channel_id = guilds_dict[str(ctx.guild.id)]
await client.get_channel(int(channel_id)).send(embed=embed)```
There is no context (ctx
) in an event. Remove the ctx, and it will work.