Manage permissions of custom commands
Learn how to manage permissions of a command
Md Shahriyar Alam
2 years ago
If you have created a slash command now you want to make it restricted to specific channel, role or permission. You can do that using the built in permission management provided by custom slash commands bot
To manage permission of a command, first go to commands page and edit the command you want to manage permission.
Then in the command you will be able to see Hooks. Hooks are made for a lot of cool stuff, but we can manage permission from here
All the codes specified below will be used in pre hook
Specicic permission
You can require one or more permissions to be needed to run a command, For that you have to use the require_permission Programmed variable
require_permission("administrator")In the code above we have required the administrator permission to must have in order to run the command you are editing.
You can also require multiple permissions
require_permission("kick_members", "ban_members")And all the possible permissions that are available create_instant_invite, kick_members, ban_members, administrator, manage_channels, manage_server, add_reactions, view_audit_log, priority_speaker, stream, read_messages, send_messages, send_tts_messages, manage_messages, embed_links, attach_files, read_message_history, mention_roles, use_external_emoji, use_external_stickers, view_server_insights, connect, speak, mute_members, deafen_members, move_members, use_voice_activity, manage_nicknames, manage_roles, manage_webhooks, manage_emojis, use_application_commands, request_to_speak, manage_events, manage_threads, create_public_threads, create_private_threads, send_messages_in_threads, moderate_members
Specific channel
To lock a command on a specific channel you can use the allowed_channels or banned_channels. Allowed channel will allow a command on a specific channel. And banned channel will ban a command on a specific channel and allow on other channels
Example:
allowed_channels(channel_id, channel_id2)
banned_channels(channel_id, channel_id2)Use whatever suits your command's use case. You can put as many channel id you want to allow or ban.
Spefific Role
You can use the allowed_roles or banned_roles in the same way as channels, just put the role ids.
you can find role id and channel id on the sidebar if you are using desktop and on the bottom if you are using phone
Loading comments…
Need help?
Have a question, a suggestion, or stuck on something? Reach out — we're happy to help.