When writing message.channel.id, shows an error (Cannot find reference 'channel' in 'message'), searched the entire Internet, similar problem as well as the solution has not found.
@bot.event
async def on_message_edit(before, after):
if message.channel.id == 1218632975441330266:
pass
else:
chan = bot.get_channel(1203013518408810497)
embed = disnake.Embed(title=f"{before.author} redacted his message",
description=f"Before: {before.content}\nAfter: {after.content}\nAuthor: {before.author.mention}\nWhere: {before.channel.mention}",
timestamp=datetime.now(), color=disnake.Colour.blue())
embed.set_author(name=after.author.name, icon_url=after.author.display_avatar)
await chan.send(embed=embed)
I know that I need to add message to the arguments, but after I add it, the "after" argument simply doesn't work, and I get an error TypeError: on_message_edit() missing 1 required positional argument: 'after', so I can't even guess how to do it..
Disnake version 2.9.1 (I checked this)
on_message_edit
is only expecting before
, and after
as an argument, you can't just pass another argument in it.
To check for the message channel id, you can use before.channel.id
, since before
and after
are of type disnake.Message:
if before.channel.id == 1218632975441330266:
return