踢球命令出错
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
权限,并且你的机器人可以与成员互动(你的机器人的最高角色高于他们的最高角色,并且该成员不是公会的所有者)。
我的踢球命令如下:
@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
权限,并且你的机器人可以与成员互动(你的机器人的最高角色高于他们的最高角色,并且该成员不是公会的所有者)。