class ApplicationCommandPermissionsManager

extends

BaseManager
export class ApplicationCommandPermissionsManager< BaseOptions, FetchSingleOptions, GuildType, CommandIdType,> extends BaseManager

Manages API methods for permissions of Application Commands.

Type Parameters

BaseOptions

FetchSingleOptions

GuildType

CommandIdType

readonly
client : Client

The client that instantiated this Manager

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.

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

fetch(
options: FetchSingleOptions
) : Promise<ApplicationCommandPermissions[]>

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

has(
options: FetchSingleOptions & { permissionId: ApplicationCommandPermissionIdResolvable; permissionType?: ApplicationCommandPermissionType; }
) : Promise<boolean>

Check whether a permission exists for a user, role, or channel

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

remove(
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[]; })
) : Promise<ApplicationCommandPermissions[]>

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

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