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

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

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

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

        检查用户是否在 discord.py 中具有权限

        时间:2023-10-11

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

              <tbody id='35Ziu'></tbody>

            <tfoot id='35Ziu'></tfoot>

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

                <small id='35Ziu'></small><noframes id='35Ziu'>

                  <bdo id='35Ziu'></bdo><ul id='35Ziu'></ul>
                  本文介绍了检查用户是否在 discord.py 中具有权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在为我的 discord.py 机器人创建一个踢命令.以下是 kick 命令可能的一些代码:

                  I am making a kick command for my discord.py bot. Here is some code that the kick command might be:

                      async kick_command(self, ctx, userName: discord.User):
                        prefix_used = ctx.prefix
                        alias_used = ctx.invoked_with
                        text = msg[len(prefix_used) + len(alias_used):]
                        if discord.User permissions = "admin":
                          try:
                            kick(User)
                          except Exception as e:
                            ee = "Error: " + e
                            await ctx.send_message(content=ee)
                  

                  我很确定 if 语句和 kick(User) 是无效的语法.你能帮帮我吗?

                  I am pretty sure the if statement and kick(User) are invalid syntax. Can you help me?

                  我的代码:点击这里

                  推荐答案

                  试试这个:

                  @bot.command()
                  @has_permissions(kick_members=True)  
                  async def kick(self, ctx, Member: discord.Member):
                            await bot.kick(Member)
                  
                  @kick.error
                  async def kick_error(error, ctx):
                     if isinstance(error, MissingPermissions):
                         await ctx.send("You don't have permission to do that!")
                  

                  别忘了导入 has_permissions:from discord.ext.commands import has_permissions

                  这篇关于检查用户是否在 discord.py 中具有权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:从内存中发送图像 下一篇:有没有办法在我的论点中包含空格?

                  相关文章

                  最新文章

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

                    <legend id='qtCZz'><style id='qtCZz'><dir id='qtCZz'><q id='qtCZz'></q></dir></style></legend>
                    <tfoot id='qtCZz'></tfoot>

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

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