UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

43 lines (40 loc) 1.71 kB
'use strict'; var pieces = require('@sapphire/pieces'); var discord_js = require('discord.js'); var Identifiers_cjs = require('../lib/errors/Identifiers.cjs'); var Precondition_cjs = require('../lib/structures/Precondition.cjs'); var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var _CorePrecondition = class _CorePrecondition extends Precondition_cjs.AllFlowsPrecondition { constructor() { super(...arguments); this.allowedTypes = [discord_js.ChannelType.GuildAnnouncement, discord_js.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_cjs.Identifiers.PreconditionGuildNewsOnly, message: "You can only run this command in server announcement channels." }); } }; __name(_CorePrecondition, "CorePrecondition"); var CorePrecondition = _CorePrecondition; void pieces.container.stores.loadPiece({ name: "GuildNewsOnly", piece: CorePrecondition, store: "preconditions" }); exports.CorePrecondition = CorePrecondition; //# sourceMappingURL=GuildNewsOnly.cjs.map //# sourceMappingURL=GuildNewsOnly.cjs.map