1
votes

how i can set kick command with a role use just that Moderator role will can use my kick command :

@client.command(pass_context = True)
async def kick(ctx, userName: discord.User):
    """Kick A User from server"""
    await client.kick(userName)
    await client.say("__**Successfully User Has Been Kicked!**__")
1
Please articulate your problem more clearly.Sam Chats
Read the discord py documentation, look for something in the lines of administrator privileges in channeluser6342059
Discord.py documentation doesn't cover commands.ext. You have to look at the github repo to learn about that.Sam Rockett

1 Answers

1
votes

You can use the commands.has_permissions decorator to ensure the caller has a specific permission.

@client.command(...)
@commands.has_permissions(kick_members=True)
async def kick(ctx, ...):
    pass

Just a word of warning though, according to the function docstring, it checks for the user having any required permission instead of all.
It is also recommended to add the bot_has_permissions check too to make sure it can actually kick users too.