简体   繁体   中英

Discord.py rewrite kick/ban commands

So, I've been learning how to make a discord bot lately and i want to make a kick/ban command. The code i have for them hasn't been working and all it does is sit there and do nothing. Its been really annoying. I can't really do much on it everyday because of school and then a half hour drive home whiile doing thing while im still in town but this is the code:

@client.command()
async def kick(ctx, member: discord.Member,*,reason=None):
  await member.kick(reason=reason)

@client.command()
async def ban(ctx, member: discord.Member,*,reason=None):
  await member.ban(reason=reason)

If the role of the user that you're trying to kick is higher than the role of the bot, then the bot cannot kick that user. Try putting the bot's role at the top of the roles, and give it administrator privileges. Also, try using @commands.has_permissions() or @commands.has_roles() to avoid unauthorized users from kicking and banning random people

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM