permanent-waves/commands/leave.ts
2024-07-20 14:41:35 -05:00

27 lines
896 B
TypeScript

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);
}
}