简体   繁体   中英

How to make a kick command in python for a discord bot

I am making a moderation bot for discord and want to add a kick command. I did some research on kick commands but none of them work. The error is:

discord.ext.commands.errors.CommandNotFound: Command "kick" is not found

Here's my code:

@commands.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason=None):
    await client.kick(member)
    await ctx.send(f'User {member} has been kick')

There is nothing like client.kick(member) . I think you are trying to do member.kick() . Here is an example of kick command:

@client.command()
async def kick(ctx, member: discord.Member, *, reason=None):
    await member.kick(reason=reason)
    await ctx.send(f'User {member} has kicked.')

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