import { Interaction } from 'discord.js'; import { subscriptions } from "../index"; import { MusicSubscription } from '../subscription'; import { formatCallbackData, waitingForResponse } from "../utils"; const notInVoiceResponse = formatCallbackData(`Permanent Waves isn't currently in a voice channel.`); const leftResponse = formatCallbackData(`Left channel.`); export const leaveCommand = { name: "leave", description: "Makes the bot leave the current voice channel" }; export async function leave(interaction: Interaction, subscription: MusicSubscription) { if (!interaction.guildId) return; await interaction.reply(waitingForResponse); if(!subscription) { await interaction.editReply(notInVoiceResponse); } else { subscription.voiceConnection.destroy(); subscriptions.delete(interaction.guildId); await interaction.editReply(leftResponse); } }