© 2026 Hedgehog Software, LLC
export class RulesPrecondition extends Precondition { public constructor(context: PieceContext, options: PieceOptions) { super(context, { ...options, name: "Rules", }); } public override async messageRun(message: Message) { const res = await this.checkUser(message.author.id); if (res) return this.ok(); return this.error({ message: "You must accept the rules to use this command.", }); } private async checkUser(userId: string) { const exists = await this.container.client.db.has(`user_${userId}`); return exists; } }
declare module "@sapphire/framework" { interface SapphireClient { db: PetDatabase; } interface Preconditions { Rules: never; } }
export class PingCommand extends Command { public constructor(context: Command.Context, options: Command.Options) { super(context, { ...options, name: "ping", description: "ping pong", preconditions: ["Rules"], }); } public async messageRun(message: Message) { return message.channel.send( `:ping_pong: | Pong! ${this.container.client.ws.ping}ms` ); } }
Join the Discord to ask follow-up questions and connect with the community
Sapphire is a next-gen object-oriented Discord.js bot framework.
2,286 Members