Discord.py - How to make a role specific command?

2019-02-28 11:25发布

I need to make a command that can only be executed by someone that has a certain role. I searched around on google and youtube to find a answer but came up with nothing

1条回答
甜甜的少女心
2楼-- · 2019-02-28 12:06

You can add a decorator on the command to restrict it to only members with specific roles or permissions. The documentation for it is here. It would look like this:

@bot.command()
@commands.has_role('RoleName')
async def command_name():

Keep in mind that the RoleName string you pass is case sensitive.

查看更多
登录 后发表回答