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

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

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

      <tfoot id='nxycA'></tfoot>

        您如何通过 discord.py 重写分配角色?

        时间:2023-09-09

                <tbody id='IEkyX'></tbody>
                <bdo id='IEkyX'></bdo><ul id='IEkyX'></ul>
                <tfoot id='IEkyX'></tfoot>

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

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

                1. 本文介绍了您如何通过 discord.py 重写分配角色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 discord.py rewrite 创建一个不和谐机器人,并在 repl.it 上托管它.我正在尝试添加角色分配,但每次尝试添加时都会出错

                  I am creating a discord bot using discord.py rewrite and am hosting iton repl.it. I am trying to add assignment of roles, but I get an error everytime I try to add it

                  我查看了堆栈溢出问题,但找不到添加角色的解决方案.我也浏览了文档,但这让我更加困惑.

                  I'be looked around stack overflow and have been unable to find a solution to adding roles. I've also looked through the documentation, but that just made me more confused.

                  import discord.utils 
                  @client.command()
                  async def role(ctx, * role):
                    user = ctx.message.author
                    role = discord.utils.get(user.guild.roles, name=f"{role}")
                    await ctx.add_roles(user, role)
                  

                  它应该将指定的角色添加到消息作者,但它只会产生这个错误

                  It should add the specified role to the message author but it just produces this error

                  File "main.py", line 18, in role
                      await ctx.add_roles(user, role)
                  AttributeError: 'Context' object has no attribute 'add_roles'
                  

                  推荐答案

                  我添加了 Alberto Poljak 的建议,它奏效了!

                  I added Alberto Poljak's suggestions and it worked!

                  import discord.utils 
                  @client.command()
                  async def role(ctx, * role: discord.Role):
                    user = ctx.message.author
                    await user.add_roles(role)
                  

                  这篇关于您如何通过 discord.py 重写分配角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:查找消息的作者 下一篇:discord.py emoji 所有服务器机器人

                  相关文章

                  最新文章

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

                2. <legend id='g5tMu'><style id='g5tMu'><dir id='g5tMu'><q id='g5tMu'></q></dir></style></legend>
                  1. <tfoot id='g5tMu'></tfoot>

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

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