UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

40 lines (38 loc) 1.54 kB
import { __name } from '../chunk-PAWJFY3S.mjs'; import { container } from '@sapphire/pieces'; import { ChannelType } from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers.mjs'; import { AllFlowsPrecondition } from '../lib/structures/Precondition.mjs'; var _CorePrecondition = class _CorePrecondition extends AllFlowsPrecondition { constructor() { super(...arguments); this.allowedTypes = [ChannelType.GuildAnnouncement, ChannelType.AnnouncementThread]; } messageRun(message) { return this.allowedTypes.includes(message.channel.type) ? this.ok() : this.makeSharedError(); } async chatInputRun(interaction) { const channel = await this.fetchChannelFromInteraction(interaction); return this.allowedTypes.includes(channel.type) ? this.ok() : this.makeSharedError(); } async contextMenuRun(interaction) { const channel = await this.fetchChannelFromInteraction(interaction); return this.allowedTypes.includes(channel.type) ? this.ok() : this.makeSharedError(); } makeSharedError() { return this.error({ identifier: Identifiers.PreconditionGuildNewsOnly, message: "You can only run this command in server announcement channels." }); } }; __name(_CorePrecondition, "CorePrecondition"); var CorePrecondition = _CorePrecondition; void container.stores.loadPiece({ name: "GuildNewsOnly", piece: CorePrecondition, store: "preconditions" }); export { CorePrecondition }; //# sourceMappingURL=GuildNewsOnly.mjs.map //# sourceMappingURL=GuildNewsOnly.mjs.map