ApplicationCommandPermissionsManager

export class ApplicationCommandPermissionsManager<BaseOptions, FetchSingleOptions, GuildType, CommandIdType,> extends BaseManager
export class ApplicationCommandPermissionsManager<BaseOptions, FetchSingleOptions, GuildType, CommandIdType,> extends BaseManager
Manages API methods for permissions of Application Commands.
NameConstraintsOptionalDefaultDescription
BaseOptionsNoNone
FetchSingleOptionsNoNone
GuildTypeNoNone
CommandIdTypeNoNone
Readonly
client:Client
The client that instantiated this Manager
Inherited from BaseManager
commandId:CommandIdType
The id of the command this manager acts on
guild:GuildType
The guild that this manager acts on
guildId:Snowflake | null
The id of the guild that this manager acts on
Add permissions to a command.
Example
// 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);
// 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);
NameTypeOptionalDescription
optionsFetchSingleOptions & EditApplicationCommandPermissionsMixinNoOptions used to add permissions
Fetches the permissions for one or multiple commands. Providing the client's id as the "command id" will fetch only * the guild level permissions
Example
// 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 one command
guild.commands.permissions.fetch({ command: '123456789012345678' })
.then(perms => console.log(`Fetched ${perms.length} overwrites`))
.catch(console.error);
Example
// 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 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);
Example
// 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);
// 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);
NameTypeOptionalDescription
optionsFetchSingleOptionsNoOptions used to fetch permissions
has(options):Promise<boolean>
Check whether a permission exists for a user, role, or channel
Example
guild.commands.permissions.has({ command: '123456789012345678', permissionId: '876543210123456789' })
.then(console.log)
.catch(console.error);
guild.commands.permissions.has({ command: '123456789012345678', permissionId: '876543210123456789' })
.then(console.log)
.catch(console.error);
NameTypeOptionalDescription
optionsFetchSingleOptions & { permissionId: ApplicationCommandPermissionIdResolvable; permissionType?: ApplicationCommandPermissionType; }NoOptions used to check permissions
Remove permissions from a command.
Example
// Remove a user permission from this command
guild.commands.permissions.remove({
command: '123456789012345678', users: '876543210123456789', token: 'TotallyRealToken',
})
.then(console.log)
.catch(console.error);
// Remove a user permission from this command
guild.commands.permissions.remove({
command: '123456789012345678', users: '876543210123456789', token: 'TotallyRealToken',
})
.then(console.log)
.catch(console.error);
Example
// Remove multiple roles from this command
guild.commands.permissions.remove({
command: '123456789012345678', roles: ['876543210123456789', '765432101234567890'], 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);
NameTypeOptionalDescription
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[]; })NoOptions used to remove permissions
Sets the permissions for the guild or a command overwrite.
Example
// 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 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);
Example
// 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);
// 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);
NameTypeOptionalDescription
optionsFetchSingleOptions & EditApplicationCommandPermissionsMixinNoOptions used to set permissions