【发布时间】:2019-07-31 03:49:20
【问题描述】:
我的 kick 命令需要帮助。我没有收到任何错误,但结果与我的预期不同,我的代码如下。
@bot.command(pass_context=True, name="kick")
@has_permissions(kick_members=True)
async def kick(ctx, *, target: Member):
if target.server_permissions.administrator:
await bot.say("Target is an admin")
else:
try:
await bot.kick(target)
await bot.say('Kicked{}'.format(member.mention))
except Exception:
await bot.say("Something went wrong")
@kick.error
async def kick_error(error, ctx):
if isinstance(error, CheckFailure):
await bot.send_message(ctx.message.channel, "You do not have permissions")
elif isinstance(error, BadArgument):
await bot.send_message(ctx.message.channel, "Could not identify target")
else:
raise error
但是命令确实踢了成员,但没有说踢了(会员名)。 相反,它说“出了点问题”。还有两个命令适用于我的 kick 命令。
【问题讨论】:
标签: python-3.x discord.py