[英]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.