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

27 lines
871 B
TypeScript

import { Interaction } from 'discord.js';
import { subscriptions } from "../index";
import { ensureVoiceConnection, formatCallbackData, waitingForResponse } from "../utils";
const nothingToSkipResponse = formatCallbackData(`The queue is empty.`);
const skippedResponse = formatCallbackData(`The song has been skipped.`);
export const skipCommand = {
name: "skip",
description: "Skips the current song"
};
export async function skip( interaction: Interaction) {
if (!interaction.guildId) return;
await ensureVoiceConnection(interaction);
const subscription = subscriptions.get(interaction.guildId);
await interaction.followUp(waitingForResponse);
if(!subscription.playing) {
await interaction.editReply(nothingToSkipResponse);
} else {
await subscription.audioPlayer.stop();
await interaction.editReply(skippedResponse);
}
}