1
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('')
        await message.add_reaction('')
        await message.add_reaction('')
        await message.add_reaction('')



        message = await client.wait_for('on_reaction_add', timeout= 10, check=lambda message: message.author == ctx.author)

        if message.reaction_add == '':
            await ctx.send("You reacted!")

Im making a command to use the help page and it edits the pre-existing help message to the category the user chooses that corresponds to the emoji they reacted for.

I have used a way that has no checks which annoys other people if they happen to react with those emojis to another message, is there are way to make a check similar to what I have already done or close to, where the message of help can be edited to the page the user wants and only works if they used the command specifically for the author that can use the emojis?

Cohen
  • 2,375
  • 3
  • 16
  • 35
  • Does this answer your question? [Discord.py-rewrite wait\_for() how do i use?](https://stackoverflow.com/questions/52571844/discord-py-rewrite-wait-for-how-do-i-use) – chluebi Dec 11 '20 at 13:32

2 Answers2

1
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!')
Łukasz Kwieciński
  • 14,992
  • 4
  • 21
  • 39
1

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

@client.command()
async def test(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)

    def check(reaction, user):#checking for reactions and user
        return user == ctx.author and str(reaction.emoji) in [paper, hammer]
    # in this case, the message author and the reaction emojis paper and hammer

    try:
        reaction, user = await client.wait_for("reaction_add", timeout = 3, check=check)
        # waiting for a reaction to be added
        if str(reaction.emoji) == paper:
            await ctx.send("You reacted!")

        if str(reaction.emoji) == hammer:
            await message.edit(content="Another reaction!")# this is for editing the message sent

    except: # Timeout error-handling
        await 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)

Bagle
  • 2,326
  • 3
  • 12
  • 36
  • It looks like it works, but It doesn't seem to edit the message for me and gives out no errors – Cohen Dec 12 '20 at 03:55