Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
182 views
in Technique[技术] by (71.8m points)

python - Kick Command Is Giving Errors

My kick command is below:

   @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:** {} 
 **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)

Error:

   Ignoring exception in on_command_error
       Traceback (most recent call last):
     File "C:UsersBKhushiAppDataLocalProgramsPythonPython36-3 
    2libsite-packagesdiscordextcommandscore.py", line 64, in wrapped
    ret = await coro(*args, **kwargs)
     File "C:UsersBKhushiDesktopggDiscordgang.py", line 42, in kick
       await member.kick()
  File "C:UsersBKhushiAppDataLocalProgramsPythonPython36- 
    32libsite-packagesdiscordmember.py", line 433, in kick
    await self.guild.kick(self, reason=reason)
  File "C:UsersBKhushiAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordguild.py", line 1268, in kick
    await self._state.http.kick(user.id, self.id, reason=reason)
  File "C:UsersBKhushiAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordhttp.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:UsersBKhushiAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordclient.py", line 227, in _run_event
    await coro(*args, **kwargs)
  File "C:UsersBKhushiDesktopggDiscordgang.py", line 96, in on_command_error
    raise error
  File "C:UsersBKhushiAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordextcommandsot.py", line 814, in invoke
    await ctx.command.invoke(ctx)
  File "C:UsersBKhushiAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordextcommandscore.py", line 682, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:UsersBKhushiAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordextcommandscore.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

i don't know wheres the error wheres the error

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your bot does not have the permissions necessary to kick the member in question. Make sure your bot has the KICK_MEMBERS permission and that your bot can interact with the member (your bot's highest role is above their highest role and the member is not the owner of the guild).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...