#need to get a list of users who reacted to a message

1 messages · Page 1 of 1 (latest)

crisp cliff
#
    @commands.command(name= 'start')
    async def start_pc(self, ctx):
        msg = await ctx.send("**React to this message to join!**")
        await msg.add_reaction('\U00002705')
                          
        await asyncio.sleep(15)
        print(1)
        users = set()
        for reaction in msg.reactions:
            async for user in reaction.users():
                users.add(user)

        print(users)

here is the code, I'm only getting set() in my terminal

alpine python
#

I think you should use a list

users = []
users.append(user)
print(users)
crisp cliff
#

alr let me try

alpine python
#

Maybe try to print msg.reactions and reaction.users to make sure the bot sees the reactions

crisp cliff
#

hm ok

crisp cliff
alpine python
#

Do you have the message intent enabled?

crisp cliff
#
intents = discord.Intents.all()
client = commands.Bot(command_prefix = ['d.','D.'], case_insensitive = True, intents = intents)
sand summit
#

Try to use

msg = await ctx.fetch_message(msg.id)
print(msg.reactions)
crisp cliff
#

alright

sand summit
#

You're welcome

crisp cliff
#

[<Member id=939848059314130984 name='gBot' discriminator='4416' bot=True nick='Pro bot made my Rad' guild=<Guild id=774883579472904222 name='Dominant' shard_id=0 chunked=True member_count=3354>>, <Member id=549587402054696960 name='Rad' discriminator='3196' bot=False nick=None guild=<Guild id=774883579472904222 name='Dominant' shard_id=0 chunked=True member_count=3354>>]

though I'm getting this whole thing while I only want the user IDs

sand summit
#

It's just returning the member objects, so you could get the ids by doing:

user_ids = [u.id for u in msg.reactions]