-1

How can I use the disnake library to write code (Discord bot) that deletes a message when a user with a special role (e.g. admin) reacts to the message?

Kyle F Hartzenberg
  • 2,567
  • 3
  • 6
  • 24
sm1le
  • 1

1 Answers1

1

You'll want the bot to use the event on_reaction_add to listen for reactions.

Then check if str(Reaction.emoji) == wrench and if Reaction.user.roles.contains(<ADMIN ROLE>).

The admin role can be found with get_role(<ROLE ID>) and the role ID can be found by sending the message \@role_name (usually \@Admin)in the discord server.


If both of those conditions are met, you'll want to run await Reaction.message.delete().


While I didn't post a working example, I hope this is helpful in giving you an idea of how such a task would be accomplished.

SanguineL
  • 1,189
  • 1
  • 7
  • 18