踢命令给出错误

时间:2019-04-18 14:44:37

标签: python bots discord discord.py discord.py-rewrite

我的踢球命令如下:

   @bot.command()
   async def kick(ctx, member: discord.Member, *,reason=None):
      d = datetime.datetime.now()
      channel = bot.get_channel(556058910566514688)
      embed=discord.Embed(title='**Kicked By:** {}# 
     {}'.format(ctx.message.author.name, 
             ctx.message.author.discriminator), colour=discord.Colour(0x7ed321), description='**Reason:** {} \n **Time:** {}/{}/{}'.format(reason, d.year, d.month, d.day))
embed.set_author(name='{}#{}'.format(member.name, member.discriminator), url="https://discordapp.com", icon_url='{}'.format(member.avatar_url, member.name, member.discriminator))
embed.set_thumbnail(url="{}".format(ctx.message.author.avatar_url))
role = discord.utils.get(ctx.guild.roles, name="Retired Staff")
if ctx.message.author.top_role < role:
        await ctx.send('```Only staff Can kick anyone```')
elif reason is None:
    await ctx.send('You can\'t kick anyone without a reason')
elif ctx.message.author.top_role > role:
    if ctx.message.author.top_role < member.top_role:
        await ctx.send('```You can\'t ban a staff member higher than you```')
    else:
        if ctx.message.author.top_role > member.top_role:
            await member.kick()
            await channel.send(embed=embed)

错误:

   Ignoring exception in on_command_error
       Traceback (most recent call last):
     File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-3 
    2\lib\site-packages\discord\ext\commands\core.py", line 64, in wrapped
    ret = await coro(*args, **kwargs)
     File "C:\Users\BKhushi\Desktop\gg\Discordgang.py", line 42, in kick
       await member.kick()
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36- 
    32\lib\site-packages\discord\member.py", line 433, in kick
    await self.guild.kick(self, reason=reason)
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\guild.py", line 1268, in kick
    await self._state.http.kick(user.id, self.id, reason=reason)
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\http.py", line 210, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: FORBIDDEN (status code: 403): Missing Permissions

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py", line 227, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\BKhushi\Desktop\gg\Discordgang.py", line 96, in on_command_error
    raise error
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\bot.py", line 814, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 682, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 73, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: FORBIDDEN (status code: 403): Missing Permissions

我不知道错误在哪里

1 个答案:

答案 0 :(得分:2)

您的漫游器没有踢出该成员所需的权限。确保您的漫游器具有KICK_MEMBERS权限,并且您的漫游器可以与成员互动(您的漫游器的最高角色高于其最高角色,并且该成员不是行会的所有者)。