From f91f277a30a081cde95805bf39adeb835be98c3f Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sun, 4 Dec 2022 01:55:58 -0500 Subject: Added repeat toggle; Did some optiminizations to the code --- commands/next.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'commands/next.js') diff --git a/commands/next.js b/commands/next.js index 88dac40..759c5bb 100644 --- a/commands/next.js +++ b/commands/next.js @@ -21,7 +21,7 @@ import { SlashCommandBuilder } from 'discord.js'; import { player } from '../backend/VoiceInitialization.js'; -import { nextAudio } from '../backend/AudioControl.js'; +import { nextAudio, playerState } from '../backend/AudioControl.js'; import { PermissionFlagsBits } from 'discord-api-types/v10'; export default { @@ -31,8 +31,12 @@ export default { .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), async execute(interaction, bot) { if (!interaction.member.voice.channel) return await interaction.reply({ content: 'You need to be in a voice channel to use this command.', ephemeral: true }); - await interaction.reply({ content: 'Playing next music', ephemeral: true }); - player.stop(); - return await nextAudio(bot); + if (playerState === 'Playing' || playerState === 'Paused') { + await interaction.reply({ content: 'Playing next music', ephemeral: true }); + player.stop(); + return await nextAudio(bot); + } else if (playerState === 'Stopped') { + return await interaction.reply({ content: 'Cannot play next music. Player is currently stopped...', ephemeral: true }); + } } }; -- cgit v1.2.3