• <small id='5oqkL'></small><noframes id='5oqkL'>

    <tfoot id='5oqkL'></tfoot>
    <legend id='5oqkL'><style id='5oqkL'><dir id='5oqkL'><q id='5oqkL'></q></dir></style></legend>

        <bdo id='5oqkL'></bdo><ul id='5oqkL'></ul>

        <i id='5oqkL'><tr id='5oqkL'><dt id='5oqkL'><q id='5oqkL'><span id='5oqkL'><b id='5oqkL'><form id='5oqkL'><ins id='5oqkL'></ins><ul id='5oqkL'></ul><sub id='5oqkL'></sub></form><legend id='5oqkL'></legend><bdo id='5oqkL'><pre id='5oqkL'><center id='5oqkL'></center></pre></bdo></b><th id='5oqkL'></th></span></q></dt></tr></i><div id='5oqkL'><tfoot id='5oqkL'></tfoot><dl id='5oqkL'><fieldset id='5oqkL'></fieldset></dl></div>
      1. 不和谐.py |为某人添加角色

        时间:2023-09-09
          • <bdo id='i9nlO'></bdo><ul id='i9nlO'></ul>
            <tfoot id='i9nlO'></tfoot>

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

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

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

                    <tbody id='i9nlO'></tbody>

                  本文介绍了不和谐.py |为某人添加角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我在制作添加角色"时遇到了麻烦.discord.py 中的命令.我不知道出了什么问题;它只是不起作用.

                  I have trouble with making an "add role" command in discord.py. I don't know what is wrong; it just doesn't work.

                  @client.command()
                  @commands.has_role("Admin")
                  async def addrole(ctx):
                      user = ctx.message.author
                      role = discord.utils.get(user.server.roles, name="Test")
                      await client.add_roles(user, role)
                  

                  推荐答案

                  from discord.ext import commands
                  from discord.utils import get
                  
                  bot = commands.Bot(command_prefix='!')
                  
                  @bot.command(pass_context=True)
                  @commands.has_role("Admin") # This must be exactly the name of the appropriate role
                  async def addrole(ctx):
                      member = ctx.message.author
                      role = get(member.server.roles, name="Test")
                      await bot.add_roles(member, role)
                  

                  我认为您的代码中唯一真正的错误是 @bot.command 装饰器中缺少 pass_context=True.你可能已经看过一些没有这个的代码,但这可能属于 discord.py

                  I think the only real mistake in your code is the lack of pass_context=True in the @bot.command decorator. You may have seen some code without this, but that likely belongs to the experimental "rewrite" branch of discord.py

                  这篇关于不和谐.py |为某人添加角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:RuntimeError:超时上下文管理器应该在任务内部使用 下一篇:Discord.py 每个用户的冷却时间不同

                  相关文章

                  最新文章

                  <tfoot id='ENuAb'></tfoot>
                • <legend id='ENuAb'><style id='ENuAb'><dir id='ENuAb'><q id='ENuAb'></q></dir></style></legend>

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

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