UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

32 lines (30 loc) 1.3 kB
import { Identifiers } from "../lib/errors/Identifiers.mjs"; import { AllFlowsPrecondition } from "../lib/structures/Precondition.mjs"; import { container } from "@sapphire/pieces"; import { ChannelType, ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from "discord.js"; //#region src/preconditions/GuildNewsThreadOnly.ts var CorePrecondition = class extends AllFlowsPrecondition { messageRun(message) { return message.thread?.type === ChannelType.AnnouncementThread ? this.ok() : this.makeSharedError(); } async chatInputRun(interaction) { return (await this.fetchChannelFromInteraction(interaction)).type === ChannelType.AnnouncementThread ? this.ok() : this.makeSharedError(); } async contextMenuRun(interaction) { return (await this.fetchChannelFromInteraction(interaction)).type === ChannelType.AnnouncementThread ? this.ok() : this.makeSharedError(); } makeSharedError() { return this.error({ identifier: Identifiers.PreconditionGuildNewsThreadOnly, message: "You can only run this command in server announcement thread channels." }); } }; container.stores.loadPiece({ name: "GuildNewsThreadOnly", piece: CorePrecondition, store: "preconditions" }); //#endregion export { CorePrecondition }; //# sourceMappingURL=GuildNewsThreadOnly.mjs.map