Skip to content Skip to sidebar Skip to footer

Waiting For Command Author's Reaction To Edit To The Help Category Page

message=await ctx.send(f'{ctx.author.mention}, after reacting to an emoji below the message will be edited to your choosen category) await message.add_reaction('📜')

Solution 1:

To condense this a little bit, I will use only two of the provided reactions.

@client.command()asyncdeftest(ctx):
    message = await ctx.send("Message that's getting reactions")
    paper = '📜'# for the sake of "I'd rather not copy and paste these emojis a lot"
    hammer = '🔨'await message.add_reaction(paper) 
    await message.add_reaction(hammer)

    defcheck(reaction, user):#checking for reactions and userreturn user == ctx.author andstr(reaction.emoji) in [paper, hammer]
    # in this case, the message author and the reaction emojis paper and hammertry:
        reaction, user = await client.wait_for("reaction_add", timeout = 3, check=check)
        # waiting for a reaction to be addedifstr(reaction.emoji) == paper:
            await ctx.send("You reacted!")

        ifstr(reaction.emoji) == hammer:
            await message.edit(content="Another reaction!")# this is for editing the message sentexcept: # Timeout error-handlingawait message.edit(content="Run command to use again!")

If you'd like, you could also include while True so the user doesn't have to constantly execute the command. Working test as seen in the image below:

Code when it works


References:

discord.Client.wait_for

discord.Message.edit

How to loop with a reaction embed menu (SO)

Solution 2:

reaction, user = await client.wait_for('reaction_add', timeout=10.0, check...)

If you read the docs about on_reaction_add, you'll see that it takes reaction and user arguments.

To edit the message:

message = reaction.message
await message.edit(content='new content!')

Post a Comment for "Waiting For Command Author's Reaction To Edit To The Help Category Page"