我想知道如何从特定的消息 ID 响应中选择随机用户。
我想知道如何使用命令 .voto <id> <Number of people>
随机选择用户。
我是韩国人,我用过翻译
答案 0 :(得分:1)
您必须使用 Message.reactions 和 fetch_message
async def voto(ctx, id, num_people):
msg = ctx.fetch_message(id)
winners = []
total_users = []
reactions = msg.reactions
for reaction in reactions:
users = await reaction.users().flatten()
for user in users:
total_users.append(user)
for I in range(num_people):
winners.append(I.name) # Add the name to winners
winners_msg = '\n'.join(winners)
await ctx.send(f"{winners_msg}\nHas won")