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

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

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

        如果用户无权踢球,则无法让 discord.py 引发错误

        时间:2023-10-10

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

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

                  <bdo id='MI7P7'></bdo><ul id='MI7P7'></ul>
                  本文介绍了如果用户无权踢球,则无法让 discord.py 引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试制作一个可以踢人的快速机器人,如果它有权这样做并且用户有权这样做,并且如果机器人没有权限或用户.但是我目前的解决方案似乎不起作用.这是处理它的代码,当您拥有权限时,该代码可以踢人,但如果机器人或用户没有权限,则不会引发错误.

                  I'm trying to make a quick bot that can kick people if it has the permission to do so and the user has the permission to do so as well as raise an error in chat if either the bot doesn't have the permissions or the user. However my current solution doesn't seem to be working. Here is the code that handles it, the code works to kick people when you have the permissions but doesn't raise an error if the bot or the user doesn't have the permissions.

                  @client.command(name = 'kick', pass_context = True)
                  @has_permissions(kick_members = True)
                  @bot_has_permissions(kick_members = True)
                  async def _kick(ctx, member : discord.Member, *, reason='No Reason Given'):
                      await member.kick(reason = reason)
                      await ctx.send(f'{member} was kicked for {reason}')
                  
                  
                  @_kick.error
                  async def kick_error(error, ctx):
                      if isinstance(error, MissingPermissions):
                          text = (f'Sorry {ctx.message.author}, you do not have permission to do that')
                          await ctx.send(text)
                  
                  

                  推荐答案

                  试试这样的:

                  @client.event
                  async def on_command_error(ctx, error):
                    if isinstance(error, commands.MissingPermissions):
                      await ctx.send("You do not have the permissions required for this command.")
                      return
                  
                    raise error
                  

                  这篇关于如果用户无权踢球,则无法让 discord.py 引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如果用户在具有特定角色时离开服务器,则禁止 下一篇:Discord.py Bot 重命名 VoiceChannel 有时只能工作

                  相关文章

                  最新文章

                • <tfoot id='NCkZc'></tfoot>
                • <small id='NCkZc'></small><noframes id='NCkZc'>

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

                    <legend id='NCkZc'><style id='NCkZc'><dir id='NCkZc'><q id='NCkZc'></q></dir></style></legend>

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