Skip to main content

Application Command Permissions

You can use defaultMemberPermissions option to set the default permissions required for a member to run the command (Just for application commands only). Setting it to 0 will prohibit anyone in a guild from using the command unless a specific overwrite is configured or the user has the Administrator permission flag.

const data = new CommandBuilder({
name: 'ping',
description: 'Pong!',
defaultMemberPermissions: PermissionFlagBits.AddReactions
})

Multiple permissions

You can require the user to have all of multiple permissions by merging them with the | bitwise OR operator (for example PermissionFlagsBits.BanMembers | PermissionFlagsBits.KickMembers). You cannot require any of multiple permissions. Discord evaluates against the combined permission bitfield!

const data = new CommandBuilder({
name: 'ping',
description: 'Pong!',
defaultMemberPermissions: PermissionFlagBits.KickMembers | PermissionFlagBits.BanMembers
})

DM permission

By default, globally-deployed commands are also available for use in DMs. You can use guildOnly option to disable this behaviour. Commands deployed to specific guilds are not available in DMs.

It doesn't make much sense for your ban command to be available in DMs, so you can add guildOnly: true to the constructor to remove it:

const data = new CommandBuilder({
name: 'ban',
description: 'Select a member and ban them.',
defaultMemberPermissions: PermissionFlagBits.BanMembers,
guildOnly: true
})