discordpy-获取对特定消息做出反应的用户列表
我正在学习discordPy,并尝试获取对特定消息做出反应的用户列表(姓名/id)。以下是我的代码:discordpy-获取对特定消息做出反应的用户列表,discord,discord.py,Discord,Discord.py,我正在学习discordPy,并尝试获取对特定消息做出反应的用户列表(姓名/id)。以下是我的代码: async def ga(self, ctx): channel = ctx.channel users = "" async for message in channel.history(limit=200): if message.id == '613850569718890495':
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}")
我没有收到任何错误消息,但也没有收到任何结果。你能指出我的代码有什么问题吗?感谢ID是整数,而不是字符串,并且是
反应。用户
是AyncIterator
,而消息。反应
是常规列表
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)}")