Boxer
Boxer
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by Boxer on 11/28/2023 in #djs-questions
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);
5 replies