检查特定用户是否对discord.py有反应

D先生

我正在寻找一个脚本来检查执行命令(ctx.message.author的用户是否对带有复选标记的消息做出了反应,它应该看起来像这样:

@client.command()
async def test(ctx):
    message = await ctx.send("Test")
    for emoji in ('✅'):
        await message.add_reaction(emoji) 
        # Here it should detect if the ctx.message.author has reacted
迪格

您可以通过用户的ID并使用进行检查wait_for

import asyncio # for the exception

@client.command()
async def test(ctx):
    message = await ctx.send("Test")
    for emoji in ('✅'):
        await message.add_reaction(emoji) 

        try:

            # the wait_for will only register if the following conditions are met
            def check(rctn, user):
                return user.id == ctx.author.id and str(rctn) == '✅'

            # timeout kwarg is optional
            rctn, user = await client.wait_for("reaction_add", check=check, timeout=30)

            # then execute your code here if the author reacts, like so:
            await ctx.send("I detected the author reacting!")

        # throws this error if user doesn't react in time
        # you won't need this if you don't provide a timeout kwarg in wait_for()
        except asyncio.TimeoutError:
            await ctx.send("Sorry, you didn't react in time!")

参考文献:

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

discord.py 检查用户是否具有特定角色

检查特定用户是否执行了discord.py命令

如何检查特定用户是否有角色?Discord js

如何检查用户是否具有特定角色discord.js v12?

Discord.js:如何检查特定用户是否具有角色?

检查用户列表是否对消息discord.py rewrite做出了反应

检查用户是否具有特定角色

如何检查用户是否提供了参数discord.py

检查.json词典是否包含用户ID discord.py

如何检查触发用户的特定角色?(discord.py)

Discord.py:检查用户是否具有列表中没有的角色ID

如何检查用户是否在 discord.py 中拥有角色?

Discord.Net - 检查用户是否具有 ManageServer 权限

检查用户是否具有Discord.net角色

Discord.Py 发送有关反应的消息

如何通过discord.js中DM中发送的命令检查用户是否在特定服务器中具有特定角色?

如何检查具有特定 ID 的用户是否存在?

如何检查用户在Meteor中是否具有特定角色

检查用户是否具有特定声明的角色

检查用户是否具有特定的Windows权限Powershell

检查用户是否在角色数组中具有特定角色

Discord bot是否可以使用Discord.py响应对特定用户的提及?

如何检查成员是否具有角色 discord.py

如何检查特定用户是否对特定表情符号做出反应?

如何在discord.py中检查用户是否为self_deaf

如何检查用户ID是否已注册到漫游器?[discord.py]

如何检查同一用户是否回复了我的discord.py机器人

提及具有特定角色的在线用户的Discord.py

(discord.py)wait_for函数不检查作者是否对消息作出反应