I'm learning discord.py and I'm trying to get the list of users (name/id) who reacted to a specific message.
Below is my code:
async def ga(self, ctx):
channel = ctx.channel
users = ""
async for message in channel.history(limit=200):
if message.id == '613850569718890495':
reactions = message.reactions
async for user in reactions.users():
users += user.name + ", "
await ctx.send(content=f"user: {users}")
I don't get any error messages or any results either. Thanks.
IDs are ints, not strings, and Reaction.users
is an AyncIterator
while Message.reactions
is a regular list
channel_id = 12345 # Replace with channel id
message_id = 613850569718890495 # Note these are ints, not strings
@commands.command()
async def ga(self, ctx):
channel = self.bot.get_channel(channel_id)
message = await channel.fetch_message(message_id)
users = set()
for reaction in message.reactions:
async for user in reaction.users():
users.add(user)
await ctx.send(f"users: {', '.join(user.name for user in users)}")