class ApplicationCommandPermissionsManager
extends
BaseManagerexport class ApplicationCommandPermissionsManager<BaseOptions, FetchSingleOptions, GuildType, CommandIdType,> extends BaseManager
Manages API methods for permissions of Application Commands.
Type Parameters
BaseOptions
FetchSingleOptions
GuildType
CommandIdType
addoptions: FetchSingleOptions & EditApplicationCommandPermissionsMixin) : Promise<ApplicationCommandPermissions[]> (
options: FetchSingleOptions & EditApplicationCommandPermissionsMixin
Add permissions to a command.
Examples:
// Add a rule to block a role from using a command
guild.commands.permissions.add({ command: '123456789012345678', token: 'TotallyRealToken', permissions: [
{
id: '876543211234567890',
type: ApplicationCommandPermissionType.Role,
permission: false
},
]})
.then(console.log)
.catch(console.error);
Overload 1
Overload 2
fetchoptions: FetchSingleOptions) : Promise<ApplicationCommandPermissions[]> (
options: FetchSingleOptions
Fetches the permissions for one or multiple commands. Providing the client's id as the "command id" will fetch only * the guild level permissions
Examples:
// Fetch permissions for one command
guild.commands.permissions.fetch({ command: '123456789012345678' })
.then(perms => console.log(`Fetched ${perms.length} overwrites`))
.catch(console.error);
// Fetch permissions for all commands in a guild
client.application.commands.permissions.fetch({ guild: '123456789012345678' })
.then(perms => console.log(`Fetched permissions for ${perms.size} commands`))
.catch(console.error);
// Fetch guild level permissions
guild.commands.permissions.fetch({ command: client.user.id })
.then(perms => console.log(`Fetched ${perms.length} guild level permissions`))
.catch(console.error);
hasoptions: FetchSingleOptions & { permissionId: ApplicationCommandPermissionIdResolvable; permissionType?: ApplicationCommandPermissionType; }) : Promise<boolean> (
options: FetchSingleOptions & { permissionId: ApplicationCommandPermissionIdResolvable; permissionType?: ApplicationCommandPermissionType; }
Check whether a permission exists for a user, role, or channel
Examples:
guild.commands.permissions.has({ command: '123456789012345678', permissionId: '876543210123456789' })
.then(console.log)
.catch(console.error);
removeoptions: (FetchSingleOptions & { token: string; channels?: readonly (GuildChannelResolvable | ChannelPermissionConstant)[]; roles?: readonly (RoleResolvable | RolePermissionConstant)[]; users: readonly UserResolvable[]; }) | (FetchSingleOptions & { token: string; channels?: readonly (GuildChannelResolvable | ChannelPermissionConstant)[]; roles: readonly (RoleResolvable | RolePermissionConstant)[]; users?: readonly UserResolvable[]; }) | (FetchSingleOptions & { token: string; channels: readonly (GuildChannelResolvable | ChannelPermissionConstant)[]; roles?: readonly (RoleResolvable | RolePermissionConstant)[]; users?: readonly UserResolvable[]; })) : Promise<ApplicationCommandPermissions[]> (
options: (FetchSingleOptions & { token: string; channels?: readonly (GuildChannelResolvable | ChannelPermissionConstant)[]; roles?: readonly (RoleResolvable | RolePermissionConstant)[]; users: readonly UserResolvable[]; }) | (FetchSingleOptions & { token: string; channels?: readonly (GuildChannelResolvable | ChannelPermissionConstant)[]; roles: readonly (RoleResolvable | RolePermissionConstant)[]; users?: readonly UserResolvable[]; }) | (FetchSingleOptions & { token: string; channels: readonly (GuildChannelResolvable | ChannelPermissionConstant)[]; roles?: readonly (RoleResolvable | RolePermissionConstant)[]; users?: readonly UserResolvable[]; })
Remove permissions from a command.
Examples:
// Remove a user permission from this command
guild.commands.permissions.remove({
command: '123456789012345678', users: '876543210123456789', token: 'TotallyRealToken',
})
.then(console.log)
.catch(console.error);
// Remove multiple roles from this command
guild.commands.permissions.remove({
command: '123456789012345678', roles: ['876543210123456789', '765432101234567890'], token: 'TotallyRealToken',
})
.then(console.log)
.catch(console.error);
setoptions: FetchSingleOptions & EditApplicationCommandPermissionsMixin) : Promise<ApplicationCommandPermissions[]> (
options: FetchSingleOptions & EditApplicationCommandPermissionsMixin
Sets the permissions for the guild or a command overwrite.
Examples:
// Set a permission overwrite for a command
client.application.commands.permissions.set({
guild: '892455839386304532',
command: '123456789012345678',
token: 'TotallyRealToken',
permissions: [
{
id: '876543210987654321',
type: ApplicationCommandPermissionType.User,
permission: false,
},
]})
.then(console.log)
.catch(console.error);
// Set the permissions used for the guild (commands without overwrites)
guild.commands.permissions.set({ token: 'TotallyRealToken', permissions: [
{
id: '123456789012345678',
permissions: [{
id: '876543210987654321',
type: ApplicationCommandPermissionType.User,
permission: false,
}],
},
]})
.then(console.log)
.catch(console.error);