简体   繁体   English

如何获取对 discord.py 中的反应做出反应的人的 id

[英]how to get id of people who reacted to a reaction in discord.py

I'm using this code to get a list of people who reacted to the reaction我正在使用此代码来获取对反应做出反应的人的列表

    new_msg = await channel.fetch_message(id)
    users = await new_msg.reactions[0].users().flatten()
    users.pop(users.index(client.user))
    if ctx.author in users:
      users.pop(users.index(ctx.author))

but I want it to return id's of people who reacted to it so after that I could use a command like this但我希望它返回对它做出反应的人的 ID,所以之后我可以使用这样的命令

user =  bot.get_user(userId)
await ctx.send(user.created_at)

and find out that how many user's account is older than n days并找出有多少用户的帐户超过 n 天

ID is a field in the user object according to the discord-py Documentation .根据discord-py 文档,ID 是用户 object 中的一个字段。

So you can just do [user.id for user in users] to get the list of IDs.因此,您只需执行[user.id for user in users]即可获取 ID 列表。 But since you want the user objects anyways, you can但既然你无论如何都想要用户对象,你可以

for user in users:
    await ctx.send(user.created_at)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让对消息中的表情符号做出反应的用户 (discord.py) - how to get the users who reacted with an emoji in a message (discord.py) Discord.py 发送消息的作者关于有多少人对某个反应做出反应的信息 - Discord.py send the author of a message information about how many people reacted with a certain reaction 反应日志显示消息作者的姓名,而不是反应的人(discord.py) - Reaction log saying the name of the message author instead of person who reacted (discord.py) Discord.py:我如何让机器人获得在给定时间内对消息做出反应的用户列表 - Discord.py: how do i make the bot get a list of users who reacted to a message in a given time 如何在discord.py中获得反应表情符号? - How to get reaction Emoji in discord.py? 如何获取对discord.py中的消息做出反应的成员列表? - How to get the list of members that reacted to a message in discord.py? 如何检测谁删除了反应 discord.py - How to detect that who removed the reaction discord.py 检查谁对 wait_for 中的消息做出反应检查 discord.py - check who reacted to a message in a wait_for check discord.py 从 discord.py 中的反应中获取表情符号 - Get emoji from reaction in discord.py 我怎样才能让对某个反应做出反应的每个人都列在一个列表中? - How can I get everyone who reacted to a certain reaction into a list?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM