UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

39 lines (36 loc) 1.58 kB
'use strict'; var discord_jsUtilities = require('@sapphire/discord.js-utilities'); var pieces = require('@sapphire/pieces'); 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 { messageRun(message) { return discord_jsUtilities.isVoiceChannel(message.channel) ? this.ok() : this.makeSharedError(); } async chatInputRun(interaction) { const channel = await this.fetchChannelFromInteraction(interaction); return discord_jsUtilities.isVoiceChannel(channel) ? this.ok() : this.makeSharedError(); } async contextMenuRun(interaction) { const channel = await this.fetchChannelFromInteraction(interaction); return discord_jsUtilities.isVoiceChannel(channel) ? this.ok() : this.makeSharedError(); } makeSharedError() { return this.error({ identifier: Identifiers_cjs.Identifiers.PreconditionGuildVoiceOnly, message: "You can only run this command in server voice channels." }); } }; __name(_CorePrecondition, "CorePrecondition"); var CorePrecondition = _CorePrecondition; void pieces.container.stores.loadPiece({ name: "GuildVoiceOnly", piece: CorePrecondition, store: "preconditions" }); exports.CorePrecondition = CorePrecondition; //# sourceMappingURL=GuildVoiceOnly.cjs.map //# sourceMappingURL=GuildVoiceOnly.cjs.map