UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

36 lines (34 loc) 1.37 kB
import { __name } from '../chunk-PAWJFY3S.mjs'; import { isVoiceChannel } from '@sapphire/discord.js-utilities'; import { container } from '@sapphire/pieces'; import { Identifiers } from '../lib/errors/Identifiers.mjs'; import { AllFlowsPrecondition } from '../lib/structures/Precondition.mjs'; var _CorePrecondition = class _CorePrecondition extends AllFlowsPrecondition { messageRun(message) { return isVoiceChannel(message.channel) ? this.ok() : this.makeSharedError(); } async chatInputRun(interaction) { const channel = await this.fetchChannelFromInteraction(interaction); return isVoiceChannel(channel) ? this.ok() : this.makeSharedError(); } async contextMenuRun(interaction) { const channel = await this.fetchChannelFromInteraction(interaction); return isVoiceChannel(channel) ? this.ok() : this.makeSharedError(); } makeSharedError() { return this.error({ identifier: Identifiers.PreconditionGuildVoiceOnly, message: "You can only run this command in server voice channels." }); } }; __name(_CorePrecondition, "CorePrecondition"); var CorePrecondition = _CorePrecondition; void container.stores.loadPiece({ name: "GuildVoiceOnly", piece: CorePrecondition, store: "preconditions" }); export { CorePrecondition }; //# sourceMappingURL=GuildVoiceOnly.mjs.map //# sourceMappingURL=GuildVoiceOnly.mjs.map