踢命令给出错误 [英] Kick Command Is Giving Errors
本文介绍了踢命令给出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的踢球命令如下:
@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
我不知道错误在哪里
推荐答案
您的漫游器没有踢出有问题成员所需的权限.确保您的漫游器具有 KICK_MEMBERS
权限,并且您的漫游器可以与成员进行交互(您的漫游器的最高角色高于其最高角色,并且该成员不是行会的所有者).
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).
这篇关于踢命令给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文