detritus

ApplicationCommandPermissionsCacheclass

Application Command Permissions Collection

On this page

Application Command Permissions Collection

A guild's command permission overwrites, keyed by guild id, then by command id (or the application id for app-wide ones)

  • Nothing fills it on its own, call fill(guildId) when a guild first needs them
  • APPLICATION_COMMAND_PERMISSIONS_UPDATE only updates guilds that were already filled
  • A new session (READY) clears it, leaving a guild (GUILD_DELETE) removes that guild
  • fill() keeps rejecting for a guild that installed the bot without applications.commands, so back off instead of retrying

Discord only enforces these for guild install slash commands, use isAllowed() for prefix and user install commands

import { Collections } from 'detritus-client';

Collections.ApplicationCommandPermissionsCache;

Constructor

Properties

enabled
boolean
fills
Map<string, Promise<void>>
protected
options
readonly
Default {}

Accessors

[toStringTag]
size
number
get

Methods

fill()

async src/collections/applicationcommandpermissions.ts:54
fill(guildId: string, force?: boolean): Promise<void>

Fetches a guild's command permissions, unless they're already cached (or force) Concurrent callers share one request, a failed request caches nothing

guildId
string
force?
boolean
Default false

isAllowed()

src/collections/applicationcommandpermissions.ts:83
isAllowed(
  guildId: string,
  commandIds: string | string[],
  channel: Channel,
  member: Member,
): boolean

Whether the guild's command permissions let this member use a command in this channel commandIds since a global command and its guild version can both have overwrites A command's own overwrites replace the app-wide ones like Discord, and nothing cached counts as allowed