Skip to main content

Interface: Preconditions

The registered preconditions and their contexts, if any. When registering new ones, it is recommended to use module augmentation so custom ones are registered.

When a key's value is never, it means that it does not take any context, which allows you to pass its identifier as a bare string (e.g. preconditions: ['NSFW']), however, if context is required, a non-never type should be passed, which will type {@link PreconditionContainerArray#append} and require an object with the name and a context with the defined type.

example

declare module '@sapphire/framework' {
interface Preconditions {
// A precondition named `Moderator` which does not read `context`:
Moderator: never;

// A precondition named `ChannelPermissions` which does read `context`:
ChannelPermissions: {
permissions: Permissions;
};
}
}

// [โœ”] These are valid:
preconditions.append('Moderator');
preconditions.append({ name: 'Moderator' });
preconditions.append({
name: 'ChannelPermissions',
context: { permissions: new Permissions(8) }
});

// [X] These are invalid:
preconditions.append({ name: 'Moderator', context: {} });
// โžก `never` keys do not accept `context`.

preconditions.append('ChannelPermissions');
// โžก non-`never` keys always require `context`, a string cannot be used.

preconditions.append({
name: 'ChannelPermissions',
context: { unknownProperty: 1 }
});
// โžก mismatching `context` properties, `{ unknownProperty: number }` is not
// assignable to `{ permissions: Permissions }`.

Properties

ClientPermissions

โ€ข ClientPermissions: Object

Type declaration

NameType
permissionsPermissions

Defined in

projects/framework/src/lib/structures/Precondition.ts:95


Cooldown

โ€ข Cooldown: CooldownContext

Defined in

projects/framework/src/lib/structures/Precondition.ts:84


DMOnly

โ€ข DMOnly: never

Defined in

projects/framework/src/lib/structures/Precondition.ts:85


Enabled

โ€ข Enabled: never

Defined in

projects/framework/src/lib/structures/Precondition.ts:86


GuildNewsOnly

โ€ข GuildNewsOnly: never

Defined in

projects/framework/src/lib/structures/Precondition.ts:87


GuildNewsThreadOnly

โ€ข GuildNewsThreadOnly: never

Defined in

projects/framework/src/lib/structures/Precondition.ts:88


GuildOnly

โ€ข GuildOnly: never

Defined in

projects/framework/src/lib/structures/Precondition.ts:89


GuildPrivateThreadOnly

โ€ข GuildPrivateThreadOnly: never

Defined in

projects/framework/src/lib/structures/Precondition.ts:90


GuildPublicThreadOnly

โ€ข GuildPublicThreadOnly: never

Defined in

projects/framework/src/lib/structures/Precondition.ts:91


GuildTextOnly

โ€ข GuildTextOnly: never

Defined in

projects/framework/src/lib/structures/Precondition.ts:92


GuildThreadOnly

โ€ข GuildThreadOnly: never

Defined in

projects/framework/src/lib/structures/Precondition.ts:93


NSFW

โ€ข NSFW: never

Defined in

projects/framework/src/lib/structures/Precondition.ts:94


UserPermissions

โ€ข UserPermissions: Object

Type declaration

NameType
permissionsPermissions

Defined in

projects/framework/src/lib/structures/Precondition.ts:98