<small id='IZA68'></small><noframes id='IZA68'>

    <tfoot id='IZA68'></tfoot>

  • <i id='IZA68'><tr id='IZA68'><dt id='IZA68'><q id='IZA68'><span id='IZA68'><b id='IZA68'><form id='IZA68'><ins id='IZA68'></ins><ul id='IZA68'></ul><sub id='IZA68'></sub></form><legend id='IZA68'></legend><bdo id='IZA68'><pre id='IZA68'><center id='IZA68'></center></pre></bdo></b><th id='IZA68'></th></span></q></dt></tr></i><div id='IZA68'><tfoot id='IZA68'></tfoot><dl id='IZA68'><fieldset id='IZA68'></fieldset></dl></div>

      <bdo id='IZA68'></bdo><ul id='IZA68'></ul>

      <legend id='IZA68'><style id='IZA68'><dir id='IZA68'><q id='IZA68'></q></dir></style></legend>

      1. discord.py “wait_for"命令中的反应

        时间:2023-10-11
        <legend id='GUKWl'><style id='GUKWl'><dir id='GUKWl'><q id='GUKWl'></q></dir></style></legend>
          • <bdo id='GUKWl'></bdo><ul id='GUKWl'></ul>

            <small id='GUKWl'></small><noframes id='GUKWl'>

              <tfoot id='GUKWl'></tfoot>

                <i id='GUKWl'><tr id='GUKWl'><dt id='GUKWl'><q id='GUKWl'><span id='GUKWl'><b id='GUKWl'><form id='GUKWl'><ins id='GUKWl'></ins><ul id='GUKWl'></ul><sub id='GUKWl'></sub></form><legend id='GUKWl'></legend><bdo id='GUKWl'><pre id='GUKWl'><center id='GUKWl'></center></pre></bdo></b><th id='GUKWl'></th></span></q></dt></tr></i><div id='GUKWl'><tfoot id='GUKWl'></tfoot><dl id='GUKWl'><fieldset id='GUKWl'></fieldset></dl></div>
                  <tbody id='GUKWl'></tbody>

                • 本文介绍了discord.py “wait_for"命令中的反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我已经写了一个命令.当您执行此命令时,机器人会向特定频道发送消息.他对此消息添加了一个反应(顺便说一句嵌入).到目前为止.但是现在,当有人点击这个反应时,我希望机器人做出回应.在这种情况下,他应该向特定频道发送消息.但这不起作用.也没有错误码,应该是可以的,只是他没有发消息.

                  I have already written a command. When you execute this command, the bot sends a message to a specific channel. He adds a reaction to this message (an embed by the way). That goes so far. But now, when someone clicks on this reaction, I wanted the bot to respond. In this case, he should send a message to a specific channel. But that doesn't work. There is also no error code, which is supposed to mean that it works, only he doesn't send a message.

                  @bot.command()
                  async def buy(ctx, choice):
                      channel = bot.get_channel(705836078082424914)
                      user = ctx.message.author
                      vcrole1 = get(user.guild.roles, id=703562188224331777)
                      messagechannel = ctx.message.channel.id
                      if ctx.message.channel.id == 705146663135871106:
                          if choice == '1':
                              if any(role.id == 703562188224331777 for role in ctx.message.author.roles):
                                  await user.remove_roles(vcrole1)
                                  await ctx.send(
                                      "not important message")
                                  messtag1 = await channel.send('not important') 
                                  await messtag1.delete(delay=None)
                  
                                  embed = discord.Embed(color=0xe02522, title='not important title', description=
                                  'not important description')
                                  embed.set_footer(text='not important text')
                                  embed.timestamp = datetime.datetime.utcnow()
                  
                                  mess1 = await channel.send(embed=embed)
                                  await mess1.add_reaction('<a:check:674039577882918931>')
                  
                                  def check(reaction, user):
                  
                                      return reaction.message == mess1 and str(reaction.emoji) ==  '<a:check:674039577882918931>'
                  
                                  await bot.wait_for('reaction_add', check=check)
                                  channeldone = bot.get_channel(705836078082424914)
                                  await channeldone.send('test')
                  

                  没有错误消息.

                  推荐答案

                  看起来你的 reaction.message == mess1 条件返回 False,我可以不要把它缩小到为什么会发生这种情况,但如果我这样做了,我会编辑它.

                  It looks as though your reaction.message == mess1 condition is returning False, and I can't narrow it down as to why that's happening, but I'll edit this if I do.

                  解决这个问题的一种方法是评估消息的 ID:

                  A way to overcome this would be to evaluate the IDs of the messages:

                  return reaction.message.id == mess1.id and str(reaction.emoji) == '<a:check:674039577882918931>'
                  

                  当机器人做出反应时,这将评估为 True,所以我建议添加另一个条件来检查用户是否做出反应,如果这是您希望用户执行的操作:

                  And this will evaluate to True when the bot reacts, so I'd recommend adding another condition to check that the user reacted, if that is what you want the user to do:

                  return .... and user == ctx.author
                  

                  <小时>

                  参考资料:

                  • Message.id
                  • discord.Member

                  这篇关于discord.py “wait_for"命令中的反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Discord.py - 如何检测用户是否提到/ping 机器人 下一篇:(Discord.py)如何让机器人在一段时间后删除自己的

                  相关文章

                  最新文章

                  <tfoot id='IrJpk'></tfoot>

                    <small id='IrJpk'></small><noframes id='IrJpk'>

                    <legend id='IrJpk'><style id='IrJpk'><dir id='IrJpk'><q id='IrJpk'></q></dir></style></legend>

                    1. <i id='IrJpk'><tr id='IrJpk'><dt id='IrJpk'><q id='IrJpk'><span id='IrJpk'><b id='IrJpk'><form id='IrJpk'><ins id='IrJpk'></ins><ul id='IrJpk'></ul><sub id='IrJpk'></sub></form><legend id='IrJpk'></legend><bdo id='IrJpk'><pre id='IrJpk'><center id='IrJpk'></center></pre></bdo></b><th id='IrJpk'></th></span></q></dt></tr></i><div id='IrJpk'><tfoot id='IrJpk'></tfoot><dl id='IrJpk'><fieldset id='IrJpk'></fieldset></dl></div>
                      • <bdo id='IrJpk'></bdo><ul id='IrJpk'></ul>