python - 获取所有对消息做出反应的用户,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)
解决方案
您需要使用其 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)
推荐阅读
- selenium - Azure Pipelines (DevOps) Selenium 自动化浏览器在内存中无头运行导致错误
- tomcat - 来自命令行的错误,但使用 URL 从网页成功执行了 A SERVLET。谢谢
- swift - 如何处理 500 个 http 错误
- java - Java mapToInt vs Reduce with map
- javascript - 每秒单击一次按钮,直到
- python - 字典值(不是键)的内置“all()”函数
- mysql - SQL IS NULL 检查未给出正确结果
- node.js - node.js 中用于数据库插入的 Redis 队列
- android - 在 Android 中使用 websocat 连接到 WSS
- ios - 如何在故事板/笔尖中查找 Xcode 中特定颜色的对象