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

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

    1. <legend id='tlM8Y'><style id='tlM8Y'><dir id='tlM8Y'><q id='tlM8Y'></q></dir></style></legend>

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

      1. <tfoot id='tlM8Y'></tfoot>

        使用 discord.py 进行反应检查

        时间:2023-09-09

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

          • <small id='plVsy'></small><noframes id='plVsy'>

              <tbody id='plVsy'></tbody>
                <legend id='plVsy'><style id='plVsy'><dir id='plVsy'><q id='plVsy'></q></dir></style></legend>
                • <bdo id='plVsy'></bdo><ul id='plVsy'></ul>

                  本文介绍了使用 discord.py 进行反应检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在研究一个命令,如果你对机器人做出同意反应,它将发送一个 nuke gif.这很好用,但是如果您选择其他选项或超时,我无法让机器人回答不同.我当前的代码如下.感谢您的帮助

                  I was working on a command which will send a nuke gif if you react bot with an agree reaction. This works fine however I cant make bot answer diffrently if you choose other option or timeout. My current code is bellow. Thanks for your help

                  async def nuke(ctx):
                      
                      yas = '✔️'
                      nay = '❌'
                      
                      message = await ctx.send("Are you sure that you want to use your nukes?")
                      
                      await message.add_reaction(yas)
                      await message.add_reaction(nay)
                      
                      
                      def check(reaction, user):
                          return user == ctx.author and str(reaction.emoji) == '✔️'
                      await bot.wait_for('reaction_add', timeout=60.0, check=check)
                          
                      embed = discord.Embed(title="Code: 759245 Activated. Destruction of Channel started")
                      embed.set_image(url="https://i.gifer.com/3Tt5.gif")
                      await ctx.send(embed=embed)
                      
                      def check(reaction, user):
                          return user == ctx.author and str(reaction.emoji) == '❌'
                      await bot.wait_for('reaction_add', timeout=60.0, check=check)
                  
                      await ctx.send("Cancelled")```
                  

                  推荐答案

                  代码从上到下,这意味着您的代码现在要执行的操作如下:

                  Code goes top to bottom, meaning that what your code will do now is the following:

                  • 等待用户做出反应'✔️'
                  • 发送gif 3Tt5
                  • 等待用户反应'❌'
                  • 发送已取消"

                  您将要编写 one 检查以检查是否使用了 任何 个可能的反应,然后以不同的方式处理所有这些反应.

                  You're gonna want to write one check that checks if any of the possible reactions was used, and then handle all of them differently.

                  yas = '✔️'
                  nay = '❌'
                  
                  valid_reactions = ['✔️', '❌']
                  
                  def check(reaction, user):
                      return user == ctx.author and str(reaction.emoji) in valid_reactions
                  reaction, user = await bot.wait_for('reaction_add', timeout=60.0, check=check)
                  
                  if str(reaction.emoji) == yas:
                      embed = # code to create the embed
                      return await ctx.send(embed=embed)
                  
                  # there's only two reactions, so if the above function didn't return, it means the second reaction (nay) was used instead
                  await ctx.send("Cancelled")
                  

                  这篇关于使用 discord.py 进行反应检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 discord.py 访问命令之间的变量 下一篇:如何按命令踢用户

                  相关文章

                  最新文章

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

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

                      <tfoot id='tbvTY'></tfoot>
                        <bdo id='tbvTY'></bdo><ul id='tbvTY'></ul>