#Only allow certain users to execute a slash command

1 messages · Page 1 of 1 (latest)

mighty wadi
#

This used to work fine but now that server members is a privileged intent it doesn't seem to work. My current code would check the role of the person executing the command, because I only want people with that role to do it. Is there any way to work around this without privileged intents?

I could have a list of people that have the role but I'd have to update that every time there is a new member. Will this work without privileged intents?

edgy anvilBOT
#

@disnake.ext.commands.default_member_permissions(value=0, **permissions)```
A decorator that sets default required member permissions for the command. Unlike [`has_permissions()`](https://docs.disnake.dev/en/stable/ext/commands/api.html#disnake.ext.commands.has_permissions "disnake.ext.commands.has_permissions"), this decorator does not add any checks. Instead, it prevents the command from being run by members without *all* required permissions, if not overridden by moderators on a guild-specific basis.

See also the `default_member_permissions` parameter for application command decorators.

Note

This does not work with slash subcommands/groups.

Example

This would only allow members with [`manage_messages`](https://docs.disnake.dev/en/stable/api.html#disnake.Permissions.manage_messages "disnake.Permissions.manage_messages") *and* [`view_audit_log`](https://docs.disnake.dev/en/stable/api.html#disnake.Permissions.view_audit_log "disnake.Permissions.view_audit_log") permissions to use the command by default, however moderators can override this and allow/disallow specific users and roles to use the command in their guilds regardless of this setting.
inner scaffold
#

Or make a cuscom check to check roles

compact socket
#

You don't need member intents to check a member's roles when handling slash command interactions since the member and their guild roles are part of the interaction payload