ApplicationCommandPermissionsManager
classe · Source
Manages API methods for permissions of Application Commands.
Extends: BaseManager
Properties
manager
private
The manager or command that this manager belongs to Source
guild
nullable
The guild that this manager acts on Source
guildId
nullable
The id of the guild that this manager acts on Source
commandId
nullable
The id of the command this manager acts on Source
client
readonly
The client that instantiated this Manager Source
Methods
permissionsPath
private
The APIRouter path to the commands Parameters
| Name | Type | Description |
|---|---|---|
guildId | Snowflake | The guild's id to use in the path, |
commandId? | Snowflake | The application command's id |
Returns: ObjectSource
fetch
async
Fetches the permissions for one or multiple commands. Parameters
| Name | Type | Description |
|---|---|---|
options? | BaseApplicationCommandPermissionsOptions | Options used to fetch permissions |
Returns: Promise<(Array<ApplicationCommandPermissions>\|Collection<Snowflake, Array<ApplicationCommandPermissions>>)>
// Fetch permissions for one command
guild.commands.permissions.fetch({ command: '123456789012345678' })
.then(perms => console.log(`Fetched permissions for ${perms.length} users`))
.catch(console.error);2
3
4
// 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);2
3
4
set
async
Sets the permissions for one or more commands. Parameters
| Name | Type | Description |
|---|---|---|
options | SetApplicationCommandPermissionsOptions | Options used to set permissions |
Returns: Promise<(Array<ApplicationCommandPermissions>\|Collection<Snowflake, Array<ApplicationCommandPermissions>>)>
// Set the permissions for one command
client.application.commands.permissions.set({ guild: '892455839386304532', command: '123456789012345678',
permissions: [
{
id: '876543210987654321',
type: 'USER',
permission: false,
},
]})
.then(console.log)
.catch(console.error);2
3
4
5
6
7
8
9
10
11
// Set the permissions for all commands
guild.commands.permissions.set({ fullPermissions: [
{
id: '123456789012345678',
permissions: [{
id: '876543210987654321',
type: 'USER',
permission: false,
}],
},
]})
.then(console.log)
.catch(console.error);2
3
4
5
6
7
8
9
10
11
12
13
add
async
Add permissions to a command. Parameters
| Name | Type | Description |
|---|---|---|
options | AddApplicationCommandPermissionsOptions | Options used to add permissions |
Returns: Promise<Array<ApplicationCommandPermissions>>
// Block a role from the command permissions
guild.commands.permissions.add({ command: '123456789012345678', permissions: [
{
id: '876543211234567890',
type: 'ROLE',
permission: false
},
]})
.then(console.log)
.catch(console.error);2
3
4
5
6
7
8
9
10
remove
async
Remove permissions from a command. Parameters
| Name | Type | Description |
|---|---|---|
options | RemoveApplicationCommandPermissionsOptions | Options used to remove permissions |
Returns: Promise<Array<ApplicationCommandPermissions>>
// Remove a user permission from this command
guild.commands.permissions.remove({ command: '123456789012345678', users: '876543210123456789' })
.then(console.log)
.catch(console.error);2
3
4
// Remove multiple roles from this command
guild.commands.permissions.remove({
command: '123456789012345678', roles: ['876543210123456789', '765432101234567890']
})
.then(console.log)
.catch(console.error);2
3
4
5
6
has
async
Check whether a permission exists for a user or role Parameters
| Name | Type | Description |
|---|---|---|
options | AddApplicationCommandPermissionsOptions | Options used to check permissions |
Returns: Promise<boolean>
// Check whether a user has permission to use a command
guild.commands.permissions.has({ command: '123456789012345678', permissionId: '876543210123456789' })
.then(console.log)
.catch(console.error);2
3
4
transformPermissions
static · private
Transforms an ApplicationCommandPermissionData object into something that can be used with the API. Parameters
| Name | Type | Description |
|---|---|---|
permissions | ApplicationCommandPermissionData | The permissions to transform |
received? | boolean | Whether these permissions have been received from Discord |
Returns: APIApplicationCommandPermissionsSource