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 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
Name | Type |
---|---|
permissions | PermissionsBitField |
Defined in
projects/framework/src/lib/structures/Precondition.ts:142
Cooldown
• Cooldown: CooldownPreconditionContext
Defined in
projects/framework/src/lib/structures/Precondition.ts:130
DMOnly
• DMOnly: never
Defined in
projects/framework/src/lib/structures/Precondition.ts:131
Enabled
• Enabled: never
Defined in
projects/framework/src/lib/structures/Precondition.ts:132
GuildNewsOnly
• GuildNewsOnly: never
Defined in
projects/framework/src/lib/structures/Precondition.ts:133
GuildNewsThreadOnly
• GuildNewsThreadOnly: never
Defined in
projects/framework/src/lib/structures/Precondition.ts:134
GuildOnly
• GuildOnly: never
Defined in
projects/framework/src/lib/structures/Precondition.ts:135
GuildPrivateThreadOnly
• GuildPrivateThreadOnly: never
Defined in
projects/framework/src/lib/structures/Precondition.ts:136
GuildPublicThreadOnly
• GuildPublicThreadOnly: never
Defined in
projects/framework/src/lib/structures/Precondition.ts:137
GuildTextOnly
• GuildTextOnly: never
Defined in
projects/framework/src/lib/structures/Precondition.ts:138
GuildThreadOnly
• GuildThreadOnly: never
Defined in
projects/framework/src/lib/structures/Precondition.ts:140
GuildVoiceOnly
• GuildVoiceOnly: never
Defined in
projects/framework/src/lib/structures/Precondition.ts:139
NSFW
• NSFW: never
Defined in
projects/framework/src/lib/structures/Precondition.ts:141
UserPermissions
• UserPermissions: Object
Type declaration
Name | Type |
---|---|
permissions | PermissionsBitField |