Skip to content

ApplicationCommandPermissionsManager

classe · Source

Manages API methods for permissions of Application Commands.

Extends: BaseManager

Properties

manager

private

manager: ApplicationCommandManager | ApplicationCommand

The manager or command that this manager belongs to Source

guild

nullable

guild: Guild

The guild that this manager acts on Source

guildId

nullable

guildId: Snowflake

The id of the guild that this manager acts on Source

commandId

nullable

commandId: Snowflake

The id of the command this manager acts on Source

client

readonly

client: Client

The client that instantiated this Manager Source

Methods

permissionsPath

private

permissionsPath(guildId: Snowflake, commandId?: Snowflake): Object

The APIRouter path to the commands Parameters

NameTypeDescription
guildIdSnowflakeThe guild's id to use in the path,
commandId?SnowflakeThe application command's id

Returns: ObjectSource

fetch

async

async fetch(options?: BaseApplicationCommandPermissionsOptions): Promise<(Array<ApplicationCommandPermissions>|Collection<Snowflake, Array<ApplicationCommandPermissions>>)>

Fetches the permissions for one or multiple commands. Parameters

NameTypeDescription
options?BaseApplicationCommandPermissionsOptionsOptions used to fetch permissions

Returns: Promise<(Array<ApplicationCommandPermissions>\|Collection<Snowflake, Array<ApplicationCommandPermissions>>)>

js
// Fetch permissions for one command
guild.commands.permissions.fetch({ command: '123456789012345678' })
  .then(perms => console.log(`Fetched permissions for ${perms.length} users`))
  .catch(console.error);
js
// 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);

Source

set

async

async set(options: SetApplicationCommandPermissionsOptions): Promise<(Array<ApplicationCommandPermissions>|Collection<Snowflake, Array<ApplicationCommandPermissions>>)>

Sets the permissions for one or more commands. Parameters

NameTypeDescription
optionsSetApplicationCommandPermissionsOptionsOptions used to set permissions

Returns: Promise<(Array<ApplicationCommandPermissions>\|Collection<Snowflake, Array<ApplicationCommandPermissions>>)>

js
// 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);
js
// 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);

Source

add

async

async add(options: AddApplicationCommandPermissionsOptions): Promise<Array<ApplicationCommandPermissions>>

Add permissions to a command. Parameters

NameTypeDescription
optionsAddApplicationCommandPermissionsOptionsOptions used to add permissions

Returns: Promise<Array<ApplicationCommandPermissions>>

js
// 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);

Source

remove

async

async remove(options: RemoveApplicationCommandPermissionsOptions): Promise<Array<ApplicationCommandPermissions>>

Remove permissions from a command. Parameters

NameTypeDescription
optionsRemoveApplicationCommandPermissionsOptionsOptions used to remove permissions

Returns: Promise<Array<ApplicationCommandPermissions>>

js
// Remove a user permission from this command
guild.commands.permissions.remove({ command: '123456789012345678', users: '876543210123456789' })
  .then(console.log)
  .catch(console.error);
js
// Remove multiple roles from this command
guild.commands.permissions.remove({
  command: '123456789012345678', roles: ['876543210123456789', '765432101234567890']
})
   .then(console.log)
   .catch(console.error);

Source

has

async

async has(options: AddApplicationCommandPermissionsOptions): Promise<boolean>

Check whether a permission exists for a user or role Parameters

NameTypeDescription
optionsAddApplicationCommandPermissionsOptionsOptions used to check permissions

Returns: Promise<boolean>

js
// Check whether a user has permission to use a command
guild.commands.permissions.has({ command: '123456789012345678', permissionId: '876543210123456789' })
 .then(console.log)
 .catch(console.error);

Source

transformPermissions

static · private

transformPermissions(permissions: ApplicationCommandPermissionData, received?: boolean): APIApplicationCommandPermissions

Transforms an ApplicationCommandPermissionData object into something that can be used with the API. Parameters

NameTypeDescription
permissionsApplicationCommandPermissionDataThe permissions to transform
received?booleanWhether these permissions have been received from Discord

Returns: APIApplicationCommandPermissionsSource

Unofficial software. Not affiliated with or supported by Discord.