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

陌路散爱 提交于 2019-12-02 10:45:09

问题


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:


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.



来源:https://stackoverflow.com/questions/49351509/discord-py-how-to-make-a-role-specific-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!