UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

39 lines (37 loc) 1.54 kB
"use strict"; const require_lib_errors_Identifiers = require('../lib/errors/Identifiers.cjs'); const require_lib_structures_Precondition = require('../lib/structures/Precondition.cjs'); let __sapphire_pieces = require("@sapphire/pieces"); let discord_js = require("discord.js"); //#region src/preconditions/GuildNewsOnly.ts var CorePrecondition = class extends require_lib_structures_Precondition.AllFlowsPrecondition { constructor(..._args) { super(..._args); 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: require_lib_errors_Identifiers.Identifiers.PreconditionGuildNewsOnly, message: "You can only run this command in server announcement channels." }); } }; __sapphire_pieces.container.stores.loadPiece({ name: "GuildNewsOnly", piece: CorePrecondition, store: "preconditions" }); //#endregion exports.CorePrecondition = CorePrecondition; //# sourceMappingURL=GuildNewsOnly.cjs.map