import { Precondition } from '@sapphire/framework';
import type {
CommandInteraction,
ContextMenuCommandInteraction,
Message,
Snowflake,
} from 'discord.js';
export class UserPrecondition extends Precondition {
#message = 'This command can only be used by the owner.';
public override chatInputRun(interaction: CommandInteraction) {
return this.doOwnerCheck(interaction.user.id);
}
public override contextMenuRun(interaction: ContextMenuCommandInteraction) {
return this.doOwnerCheck(interaction.user.id);
}
public override messageRun(message: Message) {
return this.doOwnerCheck(message.author.id);
}
private doOwnerCheck(userId: Snowflake) {
return userId === '447000659871662081'
? this.ok()
: this.error({ message: this.#message });
}
}
declare module '@sapphire/framework' {
interface Preconditions {
OwnerOnly: never;
}
}
import { Precondition } from '@sapphire/framework';
import type {
CommandInteraction,
ContextMenuCommandInteraction,
Message,
Snowflake,
} from 'discord.js';
export class UserPrecondition extends Precondition {
#message = 'This command can only be used by the owner.';
public override chatInputRun(interaction: CommandInteraction) {
return this.doOwnerCheck(interaction.user.id);
}
public override contextMenuRun(interaction: ContextMenuCommandInteraction) {
return this.doOwnerCheck(interaction.user.id);
}
public override messageRun(message: Message) {
return this.doOwnerCheck(message.author.id);
}
private doOwnerCheck(userId: Snowflake) {
return userId === '447000659871662081'
? this.ok()
: this.error({ message: this.#message });
}
}
declare module '@sapphire/framework' {
interface Preconditions {
OwnerOnly: never;
}
}