'discord.py - How to delete a 'on_message' / 'on_reaction_add' reply if reaction changes
I am new to python so forgive me if im not using the right terminology.. But my code works, I just can't seem to find the answer to another feature (I have searched documentation extensively to no avail)
On a users reaction my bot sends a message, but if the user changes their reaction I would like to delete the previous bot response that was sent from the original 'reaction' they submitted. (i.e. the user clicks the green check mark reaction by accident and changes it, I want the bot to delete the previous response from the on_reaction function)
'on_message' sends reply if content in message
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if message.channel.id == [channel_id]:
if ("?") in message.content:
if ("ranks") in message.content:
embed = discord.Embed(title="Ranks permitted by event", color=0x00C3FF)
embed.add_field(name="Beer League", value="```Open To ALL Ranks```")
embed.add_field(name="Act of Valor", value="```Bronze to Gold 3```")
embed.set_footer(text = "✅ if I was able to answer your question \n❌ if this did not answer your question")
maybe = await message.reply(embed=embed)
await maybe.add_reaction(check_mark)
await maybe.add_reaction(red_x)
Bot sends message to channel after user selects reaction
@bot.event
async def on_reaction_add(reaction, user):
channel = bot.get_channel[channel_id]
if reaction.count == 2 and reaction.emoji == "❌":
await channel.send("Sorry I could not help, a team member will assist shortly - <@&roleiD>")
if reaction.count == 2 and reaction.emoji == "✅":
await channel.send(f"{user.mention}, glad I could assist you!")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
