我试图发出一个 kick 命令,一切都很顺利,直到我开始添加一些额外的消息以防用户出错,现在我只能弄清楚如何踢会员,但消息不起作用并且让消息起作用,但机器人不会踢成员。
基本上,如果我写 members: discord.Member
,机器人会踢用户,但不显示消息,如果我写 commands.Greedy[discord.Member]
,则相反。
@bot.command()
@has_permissions(manage_roles=True, ban_members=True)
async def kick(ctx, members : commands.Greedy[discord.Member], *,reason=None):
if not members:
await ctx.send("** You need to name someone to kick **")
return
for member in members:
if bot.user == member:
embed = discord.Embed(title = "You can't kick me, I'm an almighty bot")
await ctx.send(embed=embed)
await members.kick(reason=reason)
对不起,如果已经有人问过了,似乎没有找到适合我的解决方案。 感谢您的回答。
答案 0 :(得分:0)
members
变量是一个列表,你需要在 for 循环中踢它们
for member in members:
if member == bot.user:
await ctx.send("You can't kick me")
else:
await member.kick(reason=reason)