首页 > 解决方案 > 获取所有对消息做出反应的用户,Discord Python

问题描述

我看到了以前的答案,遗憾的是它不在 Discord 的重写中。我试过做很多不同的事情,到目前为止没有任何效果。

@bot.command()
async def kickroulette(ctx):
    message = await ctx.send("React here!")
    await asyncio.sleep(10)
    user = random.choice(users who have reacted)
    await ctx.guild.kick(user)

标签: pythondiscord.py

解决方案


您需要使用其 ID 再次获取消息以获得新的反应。

@bot.command()
async def kickroulette(ctx):
    message = await ctx.send("React here!")
    await asyncio.sleep(10)
    msg = await ctx.channel.fetch_message(message.id)
    reactors = await msg.reactions[0].users().flatten()
    user = random.choice(reactors)
    await ctx.guild.kick(user)

推荐阅读