Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/161.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
discordpy-获取对特定消息做出反应的用户列表_Discord_Discord.py - Fatal编程技术网

discordpy-获取对特定消息做出反应的用户列表

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':

我正在学习discordPy,并尝试获取对特定消息做出反应的用户列表(姓名/id)。以下是我的代码:

    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)}")