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 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
permissions
permissions:
PermissionsBitField
Defined in
projects/framework/src/lib/structures/Precondition.ts:140
Cooldown
Cooldown:
CooldownPreconditionContext
Defined in
projects/framework/src/lib/structures/Precondition.ts:125
DMOnly
DMOnly:
never
Defined in
projects/framework/src/lib/structures/Precondition.ts:126
Enabled
Enabled:
never
Defined in
projects/framework/src/lib/structures/Precondition.ts:127
GuildNewsOnly
GuildNewsOnly:
never
Defined in
projects/framework/src/lib/structures/Precondition.ts:128
GuildNewsThreadOnly
GuildNewsThreadOnly:
never
Defined in
projects/framework/src/lib/structures/Precondition.ts:129
GuildOnly
GuildOnly:
never
Defined in
projects/framework/src/lib/structures/Precondition.ts:130
GuildPrivateThreadOnly
GuildPrivateThreadOnly:
never
Defined in
projects/framework/src/lib/structures/Precondition.ts:131
GuildPublicThreadOnly
GuildPublicThreadOnly:
never
Defined in
projects/framework/src/lib/structures/Precondition.ts:132
GuildTextOnly
GuildTextOnly:
never
Defined in
projects/framework/src/lib/structures/Precondition.ts:133
GuildThreadOnly
GuildThreadOnly:
never
Defined in
projects/framework/src/lib/structures/Precondition.ts:135
GuildVoiceOnly
GuildVoiceOnly:
never
Defined in
projects/framework/src/lib/structures/Precondition.ts:134
NSFW
NSFW:
never
Defined in
projects/framework/src/lib/structures/Precondition.ts:136
RunIn
RunIn:
object
types
types: readonly
ChannelType
[] |RunInPreconditionCommandSpecificData
Defined in
projects/framework/src/lib/structures/Precondition.ts:137
UserPermissions
UserPermissions:
object
permissions
permissions:
PermissionsBitField