I've setup this precondition to make sure the user is in a voice channel, when the user is in a voice channel it runs perfectly fine. But if one of the conditions is not met the error is not thrown and the command does not respond.
import { Precondition } from "@sapphire/framework";import { CommandInteraction, GuildMember, VoiceChannel } from "discord.js";import SailorMoon from "../classes/Client";export class InVoicePrecondition extends Precondition { public override async chatInputRun(interaction: CommandInteraction) { return this.checkVoiceChannel(interaction.member as GuildMember); } private async checkVoiceChannel(member: GuildMember) { const voiceChannel = member.voice.channel as VoiceChannel; console.log(voiceChannel) if (!voiceChannel) { return this.error({ message: 'You need to be in a voice channel to use this command.' }); } if (!voiceChannel.joinable || !voiceChannel.speakable) { return this.error({ message: 'I cannot join or speak in that voice channel.' }); } const client = member.client as SailorMoon; const player = client.lavalink.players.get(member.guild.id); if (player && !player.paused && voiceChannel.id !== member.guild.members.me?.voice.channel?.id) { return this.error({ message: 'You need to be in my voice channel.' }); } return this.ok(); }}declare module '@sapphire/framework' { interface Preconditions { InVoice: never; }}
import { Precondition } from "@sapphire/framework";import { CommandInteraction, GuildMember, VoiceChannel } from "discord.js";import SailorMoon from "../classes/Client";export class InVoicePrecondition extends Precondition { public override async chatInputRun(interaction: CommandInteraction) { return this.checkVoiceChannel(interaction.member as GuildMember); } private async checkVoiceChannel(member: GuildMember) { const voiceChannel = member.voice.channel as VoiceChannel; console.log(voiceChannel) if (!voiceChannel) { return this.error({ message: 'You need to be in a voice channel to use this command.' }); } if (!voiceChannel.joinable || !voiceChannel.speakable) { return this.error({ message: 'I cannot join or speak in that voice channel.' }); } const client = member.client as SailorMoon; const player = client.lavalink.players.get(member.guild.id); if (player && !player.paused && voiceChannel.id !== member.guild.members.me?.voice.channel?.id) { return this.error({ message: 'You need to be in my voice channel.' }); } return this.ok(); }}declare module '@sapphire/framework' { interface Preconditions { InVoice: never; }}