简体   繁体   中英

Discord.py bot delete its message upon reaction add by user

So I have made a suggestion command using discord.py and here is the current code:

@client.command()
async def suggest(ctx, *, args):
    await ctx.message.add_reaction("🗑️")
    channel1 = client.get_channel(channel_id)
    embed = discord.Embed(title = "Suggestion from: " + ctx.author.name, color = 1752220)
    embed.set_author(name = ctx.author.name, icon_url = ctx.author.avatar_url)
    embed.add_field(name = "Author's Suggestion:", value = args)
    msg = await channel1.send(embed = embed)
    await msg.add_reaction("⬆")
    await msg.add_reaction("⬇") 

So when someone types.suggest it sends the embed and added the poll reactions to it in the dedicated channel and also adds a dustbin reaction to the command usage message.

Now I want that when someone reacts on that dustbin emoji then the bot should delete the embedded suggestion but I can't make it do that.

Please help me for the same...

So I have made a suggestion command using discord.py and here is the current code:

@client.command()
async def suggest(ctx, *, args):
    await ctx.message.add_reaction("🗑️")
    channel1 = client.get_channel(channel_id)
    embed = discord.Embed(title = "Suggestion from: " + ctx.author.name, color = 1752220)
    embed.set_author(name = ctx.author.name, icon_url = ctx.author.avatar_url)
    embed.add_field(name = "Author's Suggestion:", value = args)
    msg = await channel1.send(embed = embed)
    await msg.add_reaction("⬆")
    await msg.add_reaction("⬇") 

So when someone types.suggest it sends the embed and added the poll reactions to it in the dedicated channel and also adds a dustbin reaction to the command usage message.

Now I want that when someone reacts on that dustbin emoji then the bot should delete the embedded suggestion but I can't make it do that.

Please help me for the same...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM