• <legend id='SIl1J'><style id='SIl1J'><dir id='SIl1J'><q id='SIl1J'></q></dir></style></legend>

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

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

      <tfoot id='SIl1J'></tfoot>

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

        Python Discord Bot - python clear_reaction() 清除所有反应

        时间:2023-10-10
            <bdo id='CHifF'></bdo><ul id='CHifF'></ul>
              <tfoot id='CHifF'></tfoot>

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

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

                  <tbody id='CHifF'></tbody>

                • 本文介绍了Python Discord Bot - python clear_reaction() 清除所有反应而不是特定反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 python 制作一个 Discord Bot,我希望一条消息只有某些反应,并且在添加反应时,我希望代码删除每个不需要的反应.我真的希望它验证是否没有其他反应要删除,而不仅仅是刚刚添加的那个.

                  I am making a Discord Bot using python and I want a message to have only certain reactions and on adding a reaction I want the code to delete every unwanted one. I really want it to verify if there is no other reactions to remove, not only the one that has just been added.

                  如标题所述,我的问题是我不知道为什么,但 clear_reaction() 清除了所有反应.

                  My problem, as said in the title, is that I don't know why but clear_reaction() clears all reactions.

                  这是我的代码:

                  inter_totale = ["✅", "❌"]
                  
                  
                  @bot.event
                  async def on_raw_reaction_add(payload):
                      emoji, user, member, channel = payload.emoji, await bot.fetch_user(user_id=payload.user_id), payload.member, bot.get_channel(payload.channel_id)
                      msg = await channel.fetch_message(payload.message_id)
                  
                      if payload.message_id == specific_message:
                          if inter_totale.count(emoji.name):
                              pass #  NOT DONE YET
                  
                          else:  #  deletes unwanted reactions
                              for r in msg.reactions:
                                  if not inter_totale.count(r.emoji):
                                      await msg.clear_reaction(r)
                  

                  谢谢.

                  推荐答案

                  这将删除所有反应而不是机器人它.

                  This is going to remove all reactions instead of the bot it.

                  你可以做这样的事情.if 语句只是为了检查它是否不是机器人本身,它会删除所有不是机器人做出的反应.

                  You can do something like this. The if statement is just to check if it is not the bot itself, it will remove all reactions not made by the bot.

                  @bot.event
                  async def on_raw_reaction_add(payload):
                      channel = await bot.fetch_channel(payload.channel_id)
                      message = await channel.fetch_message(payload.message_id)
                      reaction = discord.utils.get(message.reactions, emoji=payload.emoji.name)
                      inter_totale = ["✅", "❌"]
                  
                      if user.id != bot.user.id and payload.emoji.name not in inter_total:
                          await reaction.remove(payload.member)
                  
                  

                  这篇关于Python Discord Bot - python clear_reaction() 清除所有反应而不是特定反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:403 Forbidden(错误代码:50001):添加角色时缺少访问权 下一篇:启动时加载不和谐机器人时出错.通过 repl.it 托管

                  相关文章

                  最新文章

                  • <bdo id='FDtVI'></bdo><ul id='FDtVI'></ul>

                  <tfoot id='FDtVI'></tfoot>

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

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

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