Member Permissions for subcommand groups?

Are we able to add member permissions to subcommand groups? I have a SlashCommandBuilder command group for channel related actions. Some commands should only be available for admins and some for mods... But I only see that we are able to add DefaultMemberPermissions to the SlashCommandBuilder as a whole:
xport const channelSlashCommand: SlashCommandBuilder =
new SlashCommandBuilder()
.setName('channel')
.setDescription('Set of admin commands for channel management')
.addSubcommandGroup((group) =>
group
.setName('admin')
.setDescription('Add, remove, list channels from db')
.addSubcommand((subcommand) =>
subcommand
.setName('add')
.setDescription('Add chanel to DB')
.addChannelOption((option) =>
option
.setName('channel')
.setDescription('Select the channel you want to set')
.addChannelTypes(ChannelType.GuildText)
.setRequired(true),
)
.addStringOption((option) =>
option
.setName('type')
.setDescription("The channel's type")
.addChoices(
{ name: 'Announcement', value: 'announcement' },
{ name: 'General', value: 'general' },
{ name: 'Success', value: 'success' },
)
.setRequired(true),
)
.addRoleOption((option) =>
option
.setName('role')
.setDescription(
'Select the role you want to alert when sending messages to this channel',
),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName('delete')
.setDescription('delete a channel from db')
.addStringOption((option) =>
option
.setName('channel_id')
.setDescription('Enter the channel ID')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand.setName('list').setDescription('List current channels'),
),
)
.addSubcommandGroup((group) =>
group
.setName('mod')
.setDescription('Channel management commands for mods')
.addSubcommand((subcommand) =>
subcommand
.setName('lock')
.setDescription('Lock a channel')
.addChannelOption((option) =>
option
.setName('channel')
.setDescription('Channel to lock')
.setRequired(true),
),
),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator);
xport const channelSlashCommand: SlashCommandBuilder =
new SlashCommandBuilder()
.setName('channel')
.setDescription('Set of admin commands for channel management')
.addSubcommandGroup((group) =>
group
.setName('admin')
.setDescription('Add, remove, list channels from db')
.addSubcommand((subcommand) =>
subcommand
.setName('add')
.setDescription('Add chanel to DB')
.addChannelOption((option) =>
option
.setName('channel')
.setDescription('Select the channel you want to set')
.addChannelTypes(ChannelType.GuildText)
.setRequired(true),
)
.addStringOption((option) =>
option
.setName('type')
.setDescription("The channel's type")
.addChoices(
{ name: 'Announcement', value: 'announcement' },
{ name: 'General', value: 'general' },
{ name: 'Success', value: 'success' },
)
.setRequired(true),
)
.addRoleOption((option) =>
option
.setName('role')
.setDescription(
'Select the role you want to alert when sending messages to this channel',
),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName('delete')
.setDescription('delete a channel from db')
.addStringOption((option) =>
option
.setName('channel_id')
.setDescription('Enter the channel ID')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand.setName('list').setDescription('List current channels'),
),
)
.addSubcommandGroup((group) =>
group
.setName('mod')
.setDescription('Channel management commands for mods')
.addSubcommand((subcommand) =>
subcommand
.setName('lock')
.setDescription('Lock a channel')
.addChannelOption((option) =>
option
.setName('channel')
.setDescription('Channel to lock')
.setRequired(true),
),
),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator);
3 Replies
d.js toolkit
d.js toolkit13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
treble/luna
treble/luna13mo ago
You can only set permissions on the parent command
Boxer
BoxerOP13mo ago
SadBacon you
Want results from more Discord servers?
Add your server