new ApplicationCommandPermissionsCache
src/collections/applicationcommandpermissions.ts:45new ApplicationCommandPermissionsCache(
client: ShardClient,
options?: boolean | ApplicationCommandPermissionsOptions,
)Application Command Permissions Collection
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)
fill(guildId) when a guild first needs themAPPLICATION_COMMAND_PERMISSIONS_UPDATE only updates guilds that were already filledREADY) clears it, leaving a guild (GUILD_DELETE) removes that guildfill() keeps rejecting for a guild that installed the bot without applications.commands, so back off instead of retryingDiscord only enforces these for guild install slash commands, use isAllowed() for prefix and user install commands
import { Collections } from 'detritus-client';
Collections.ApplicationCommandPermissionsCache;new ApplicationCommandPermissionsCache(
client: ShardClient,
options?: boolean | ApplicationCommandPermissionsOptions,
)[iterator](): IterableIterator<[string, ApplicationCommandPermissions]>clear(): voiddelete(cacheKey: string): booleandelete(cacheKey: string | null | undefined, key: string): booleanfill(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
forEach(
func: (v: ApplicationCommandPermissions, k: string, map: Map<string, ApplicationCommandPermissions>) => void,
thisArg?: any,
): voidget(cacheKey: string): BaseCollection<string, ApplicationCommandPermissions> | undefinedget(
cacheKey: string | null | undefined,
key: string,
): ApplicationCommandPermissions | undefinedgetOrInsert(
cacheKey: string,
key: string,
defaultValue: ApplicationCommandPermissions,
): ApplicationCommandPermissionsgetOrInsertComputed(
cacheKey: string,
key: string,
func: (key: string) => ApplicationCommandPermissions,
): ApplicationCommandPermissionshas(cacheKey: string): booleanhas(cacheKey: string | null | undefined, key: string): booleaninsert(permission: ApplicationCommandPermissions): voidinsertCache(cacheKey: string): BaseCollection<string, ApplicationCommandPermissions>isAllowed(
guildId: string,
commandIds: string | string[],
channel: Channel,
member: Member,
): booleanWhether 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
keys(): IterableIterator<string>set(cacheKey: string, key: string, value: ApplicationCommandPermissions): thissetEnabled(value: boolean): voidvalues(): IterableIterator<ApplicationCommandPermissions>