0
votes

I am trying to make an command for hosting events within discord. How I am trying to get it to work is when any users react to the message's pre-sent reaction the field "entered" is edited to add the username of any user that reacts. I have got the bot to await for a reaction and it effectively edits an embedded message to add a field. Problem is i need it to accept more then one users reaction (multiple users) and update the field every time so it shows everyone who has reacted in the embed field. The code I have right now works for the first user but stops working for anyone after that.

Here is my code so far:

# Event creation command
@bot.command()
async def eventcreate(ctx, arg1, arg2):
    eventembed = discord.Embed(
        title= ":partying_face: GIVEAWAY!!! :partying_face:",
        color=7419530
    )
    eventembed.add_field(
        name= "Event",
        value=arg1,
        inline=False
    )
    eventembed.add_field(
        name= "Prize",
        value=arg2,
        inline=False
    )
    message = await ctx.send(embed=eventembed)
    await message.add_reaction('????')

    def check (reaction, user):
        return str(reaction.emoji) == '????' and user != bot.user
    while True:
        try:
            reaction, user = await bot.wait_for('reaction_add', timeout=604800, check=check)

            if str(reaction.emoji) == '????':
                reacted = user.name
                eventembed.add_field(
                    name= "Entered:",
                    value= f"```{reacted}```",
                    inline=False
                )
                await message.edit(embed=eventembed)
                await message.remove_reaction(reaction, user)

        except asyncio.TimeoutError:
            await message.remove_reaction('????')

Any help with this would be greatly appreciated. Thanks in advance!!

1

1 Answers

0
votes

This is because the await bot.wait_for only waits for 1 event. You'll need to put that inside a loop.