且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Discord.py - 如何制作特定于角色的命令?

更新时间:2023-11-30 12:11:58

您可以在命令上添加一个装饰器,以将其限制为仅具有特定角色或权限的成员.它的文档是 这里.它看起来像这样:

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():

请记住,您传递的 RoleName 字符串区分大小写.

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