ยฉ 2026 Hedgehog Software, LLC
//@ts-ignore import { AllFlowsPrecondition, Piece, Result } from "@sapphire/framework"; import { GuildMemberRoleManager, type CacheType, type ChatInputCommandInteraction, type ContextMenuCommandInteraction, } from "discord.js"; export class UserPrecondition extends AllFlowsPrecondition { public constructor(context: Piece.Context, options: AllFlowsPrecondition.Options) { super(context, { ...options, position: 20, }); } public override chatInputRun(interaction: ChatInputCommandInteraction) { return this.chackUserRole(interaction); } public override contextMenuRun(interaction: ContextMenuCommandInteraction) { return this.chackUserRole(interaction); } public override messageRun() { return this.ok(); } private async checkUserRole( interaction: ChatInputCommandInteraction<CacheType> | ContextMenuCommandInteraction<CacheType> ) { const roles = (interaction.member?.roles as GuildMemberRoleManager).cache; // Role "Member" if (roles.some((role: { id: string }) => role.id === "1165714233938427944")) { return this.ok(); } else { return this.error({ message: 'You must register on the website first!' }); } } }
chatInputCommandDenied
contextMenuCommandDenied
commandDenied