等待用户对PM中的表情符号做出反应

时间:2019-11-05 18:44:46

标签: python discord.py

我的机器人在我使用的botcommand中使用了botcommand后,向用户发送了私人消息

我已经进行了多次搜索,我不能使用on_reaction_add,因为我不希望用户到处都对该表情符号做出反应。我使用表情符号1来给他们选择。

                message = await ctx.message.author.send(embed=embed)
                await message.add_reaction("1\N{COMBINING ENCLOSING KEYCAP}")
                def make_sequence(seq):
                    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

                emoji1="1\N{COMBINING ENCLOSING KEYCAP}"
                check = reaction_check(message=message, author=ctx.author, emoji=(emoji1))
                try: 
                    reaction, user = await client.wait_for('reaction_add', timeout=10.0, check=check)
                    if reaction.emoji == emoji1:
                        print("Hello there")
                except TimeoutError:
                    print("bad")

它什么都不做:S,它会超时。

0 个答案:

没有答案