Interaction Permission Options
Issue:
Currently, the slash command permissions are too limited. You can only enable or disable commands for certain users/roles, which can be cumbersome to do.
Response:
You should be able to enable/disable commands bases on the permissions a user has. For example, you could have a purge command that will bulk delete messages. Currently I would have a create a role and give this role to all of the users that I want to be able to use the command. Instead I would like to only have this command available to users with the `MANAGE_MESSAGES` permission as they can delete messages normally. Then I can add the slash command to multiple server without worrying about roles, or users, that should be able to access the command.
Changes:
Rather than limit the permissions object to only a user or role ID, allow it to be a permissions flag, too.
Old:
MODERATOR_ROLE_ID = "<moderator_role_id>"
USER_ID = "<user_id>"
url = "https://discord.com/api/v8/applications/<my_application_id>/guilds/<my_guild_id>/commands/<my_command_id>/permissions"
json = { "permissions": [ { "id": MODERATOR_ROLE_ID, "type": 1, "permission": True },
{
"id": USER_ID,
"type": 2,
"permission": True
} ] } headers = { "Authorization": "Bot 123456" } r = requests.put(url, headers=headers, json=json)
New:
MODERATOR_ROLE_ID = "<moderator_role_id>"
USER_ID = "<user_id>"
PERMISSION_BIT_SET = "8192"
url = "https://discord.com/api/v8/applications/<my_application_id>/guilds/<my_guild_id>/commands/<my_command_id>/permissions"
json = {
"permissions": [
{
"id": MODERATOR_ROLE_ID,
"type": 1,
"permission": True
},
{
"id": USER_ID,
"type": 2,
"permission": True
},
{
"permissions": PERMISSION_BIT_SET,
"type": 3,
"permission": True
}
]
}
headers = {
"Authorization": "Bot 123456"
}
r = requests.put(url, headers=headers, json=json)
-
Làm sao để làm
-1 -
That soinds like a great idea, it would resolve some complexity in the code.
1
Vous devez vous connecter pour laisser un commentaire.
Commentaires
2 commentaires