<bdo id='99Klp'></bdo><ul id='99Klp'></ul>
    1. <legend id='99Klp'><style id='99Klp'><dir id='99Klp'><q id='99Klp'></q></dir></style></legend>

      <tfoot id='99Klp'></tfoot>

    2. <i id='99Klp'><tr id='99Klp'><dt id='99Klp'><q id='99Klp'><span id='99Klp'><b id='99Klp'><form id='99Klp'><ins id='99Klp'></ins><ul id='99Klp'></ul><sub id='99Klp'></sub></form><legend id='99Klp'></legend><bdo id='99Klp'><pre id='99Klp'><center id='99Klp'></center></pre></bdo></b><th id='99Klp'></th></span></q></dt></tr></i><div id='99Klp'><tfoot id='99Klp'></tfoot><dl id='99Klp'><fieldset id='99Klp'></fieldset></dl></div>
      1. <small id='99Klp'></small><noframes id='99Klp'>

        “NoneType"对象没有属性“remove_roles" Disc

        时间:2023-09-10

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

            <legend id='Pdg0o'><style id='Pdg0o'><dir id='Pdg0o'><q id='Pdg0o'></q></dir></style></legend>
          • <tfoot id='Pdg0o'></tfoot>
              • <bdo id='Pdg0o'></bdo><ul id='Pdg0o'></ul>

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

                  本文介绍了“NoneType"对象没有属性“remove_roles" Discord.py的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  reaction_remove 不断出现错误,只是复制粘贴了我的整个代码(减去客户端 ID),因为它可能会有所帮助,我不知道有什么问题,因为前半部分工作得很好.

                  Keep getting an error for the reaction_remove, just copy-pasted my whole code(minus the client id) cause it might help, I have no idea what's wrong as the first half works perfectly fine.

                  另外,尝试添加"如果成员不是无:等待 member.remove_roles(角色)别的:打印(错误)"最后,每次我尝试删除角色时都会出错,以防万一它有帮助.

                  Also, trying to add "if member is not None: await member.remove_roles(role) else: Print(error)" at the very end and itgave me errors every time I tried removing roles, just in case it helps.

                  import discord
                  
                  client = discord.Client()
                  
                  @client.event 
                  async def on_ready():
                      print('We have logged in as {0.user}'.format(client))
                  
                  @client.event 
                  async def on_raw_reaction_add(payload):
                      message_id = payload.message_id
                      
                      if message_id == 806406876593127464:
                          guild_id = payload.guild_id
                          guild = discord.utils.find(lambda g : g.id == guild_id, client.guilds)
                          if payload.emoji.name == "049":
                              role = discord.utils.get(guild.roles, name = 'SCP-049')
                          elif payload.emoji.name == "0492":
                              role = discord.utils.get(guild.roles, name = 'SCP-049-2')
                          elif payload.emoji.name == "096":
                              role = discord.utils.get(guild.roles, name = 'SCP-096')
                          elif payload.emoji.name == "106":
                              role = discord.utils.get(guild.roles, name = 'SCP-106')
                          elif payload.emoji.name == "173":
                              role = discord.utils.get(guild.roles, name = 'SCP-173')
                          elif payload.emoji.name == "682":
                              role = discord.utils.get(guild.roles, name = 'SCP-682')
                          elif payload.emoji.name == "939":
                              role = discord.utils.get(guild.roles, name = 'SCP-939')
                          elif payload.emoji.name == "999":
                              role = discord.utils.get(guild.roles, name = 'SCP-999')
                          elif payload.emoji.name == "Chaos":
                              role = discord.utils.get(guild.roles, name = 'Chaos Insurgency')
                          elif payload.emoji.name == "DClass":
                              role = discord.utils.get(guild.roles, name = 'D-Class')
                          elif payload.emoji.name == "MTF":
                              role = discord.utils.get(guild.roles, name = 'MTF')
                          elif payload.emoji.name == "Scientist":
                              role = discord.utils.get(guild.roles, name = 'Scientist')
                  
                          member = payload.member
                          await member.add_roles(role)
                  
                  @client.event 
                  async def on_raw_reaction_remove(payload):
                      message_id = payload.message_id
                      
                      if message_id == 806406876593127464:
                          guild_id = payload.guild_id
                          guild = discord.utils.find(lambda g : g.id == guild_id, client.guilds)
                          if payload.emoji.name == "049":
                              role = discord.utils.get(guild.roles, name = 'SCP-049')
                          elif payload.emoji.name == "0492":
                              role = discord.utils.get(guild.roles, name = 'SCP-049-2')
                          elif payload.emoji.name == "096":
                              role = discord.utils.get(guild.roles, name = 'SCP-096')
                          elif payload.emoji.name == "106":
                              role = discord.utils.get(guild.roles, name = 'SCP-106')
                          elif payload.emoji.name == "173":
                              role = discord.utils.get(guild.roles, name = 'SCP-173')
                          elif payload.emoji.name == "682":
                              role = discord.utils.get(guild.roles, name = 'SCP-682')
                          elif payload.emoji.name == "939":
                              role = discord.utils.get(guild.roles, name = 'SCP-939')
                          elif payload.emoji.name == "999":
                              role = discord.utils.get(guild.roles, name = 'SCP-999')
                          elif payload.emoji.name == "Chaos":
                              role = discord.utils.get(guild.roles, name = 'Chaos Insurgency')
                          elif payload.emoji.name == "DClass":
                              role = discord.utils.get(guild.roles, name = 'D-Class')
                          elif payload.emoji.name == "MTF":
                              role = discord.utils.get(guild.roles, name = 'MTF')
                          elif payload.emoji.name == "Scientist":
                              role = discord.utils.get(guild.roles, name = 'Scientist')
                  
                          member = payload.member
                          await member.remove_roles(role)
                  client.run()
                  

                  添加反应后可以给我一个角色,但删除该反应后无法删除该角色这里

                  It was able to give me a role after adding a reaction, but has not been able to remove the role after removing that reaction here

                  推荐答案

                  以下答案是使此代码正常工作的解决方案的一部分,因此请实施提供的答案.我在另一个问题中发现,在文档中 payload.member 只有在 event_typeREACTION_ADD 时才可用,所以我通过添加来修复它:

                  The below answer is one part of the solution to make this code work so implement the provided answer. I found out in another issue that in the documentation payload.member is only available if the event_type is REACTION_ADD so i fixed it by adding:

                  intents = discord.Intents.default()
                  intents.members = True 
                  
                  client = discord.Client(intents=intents)     
                  

                  添加后,更改

                  member = payload.member 
                  

                  member = guild.get_member(payload.user_id)
                  

                  这对我有用,如果有帮助,请告诉我.

                  That is what worked for me let me know if this helps.

                  这篇关于“NoneType"对象没有属性“remove_roles" Discord.py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用上下文在同一行中定义的上下文设置默 下一篇:为什么我可以使用 bot.get_user 函数获得一些用户,

                  相关文章

                  最新文章

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

                    1. <small id='jj79W'></small><noframes id='jj79W'>