我的bot.wait_for没有返回任何消息,但使用支票即时消息处理其他代码

时间:2019-07-12 14:29:06

标签: python discord.py-rewrite

我想问一个问题,在消息中添加两个反应,如果它们以某种反应做出响应,il做某事,如果他们以另一种响应做出响应,则il做其他事情,但是等待即时通讯不返回任何东西,就像它不接受任何输入

ive尝试了一项检查,检查它是否是一个私有通道,以及作者是否是用户,但最初是为了等待消息,所以我停止使用它,并使用了来自堆栈溢出的某人的反应检查,该方法不起作用要么

        if seq is None:
            return ()
        if isinstance(seq, Sequence) and not isinstance(seq, str):
            return seq
        else:
            return (seq,)

    def reaction_check(message=None, emoji=None, author=None, ignore_bot=True):
        message = make_sequence(message)
        message = tuple(m.id for m in message)
        emoji = make_sequence(emoji)
        author = make_sequence(author)
        def check(reaction, user):
            if ignore_bot and user.bot:
                return False
            if message and reaction.message.id not in message:
                return False
            if emoji and reaction.emoji not in emoji:
                return False
            if author and user not in author:
                return False
            return True
        return check


    servmsg = await user.send("**Which Server Were You Banned From(React Below)**")
    await servmsg.add_reaction("<:playroom:553266953335341056>")
    await servmsg.add_reaction("<:finesse:553266956149719050>")
    print("owo1")
    def check(m):
        return isinstance(m.channel, discord.abc.PrivateChannel) and m.author.id == user.id
    print("owo hello")
    try:
        reaction, user = await bot.wait_for("add_reaction", check=reaction_check(message=servmsg, author=user), timeout=500.00) 
    except asyncio.TimeoutError:
        await user.send("You Have Ran Out Of Time")
    print("reaction waitfor works")
    if str(reaction.emoji) == "<:finesse:553266956149719050>":

我没有收到任何错误,但我希望它检查所使用的表情符号是否至少是两个表情符号之一

1 个答案:

答案 0 :(得分:0)

您需要等待"reaction_add",而不是"add_reaction"wait_for的参数基于事件的名称:on_reaction_add