@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
32 lines (30 loc) • 1.14 kB
JavaScript
import { Identifiers } from "../lib/errors/Identifiers.mjs";
import { AllFlowsPrecondition } from "../lib/structures/Precondition.mjs";
import { container } from "@sapphire/pieces";
import { isVoiceChannel } from "@sapphire/discord.js-utilities";
//#region src/preconditions/GuildVoiceOnly.ts
var CorePrecondition = class extends AllFlowsPrecondition {
messageRun(message) {
return isVoiceChannel(message.channel) ? this.ok() : this.makeSharedError();
}
async chatInputRun(interaction) {
return isVoiceChannel(await this.fetchChannelFromInteraction(interaction)) ? this.ok() : this.makeSharedError();
}
async contextMenuRun(interaction) {
return isVoiceChannel(await this.fetchChannelFromInteraction(interaction)) ? this.ok() : this.makeSharedError();
}
makeSharedError() {
return this.error({
identifier: Identifiers.PreconditionGuildVoiceOnly,
message: "You can only run this command in server voice channels."
});
}
};
container.stores.loadPiece({
name: "GuildVoiceOnly",
piece: CorePrecondition,
store: "preconditions"
});
//#endregion
export { CorePrecondition };
//# sourceMappingURL=GuildVoiceOnly.mjs.map