From 1cd0056d71ab84421b40538ff7b0bb76a2e6a766 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 11 Jul 2022 23:14:58 -0400 Subject: Fully implemented order playlist --- commands/reshuffle.js | 12 +++++++++--- commands/status.js | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'commands') diff --git a/commands/reshuffle.js b/commands/reshuffle.js index 162a52e..e4e6745 100644 --- a/commands/reshuffle.js +++ b/commands/reshuffle.js @@ -22,6 +22,9 @@ import { SlashCommandBuilder } from '@discordjs/builders'; import { player, shufflePlaylist } from '../AudioBackend.js'; import { PermissionFlagsBits } from 'discord-api-types/v10'; +import { readFileSync } from 'node:fs'; +// import config from './config.json' assert {type: 'json'} +const { shuffle } = JSON.parse(readFileSync('./config.json')); export default { data: new SlashCommandBuilder() @@ -29,8 +32,11 @@ export default { .setDescription('Reshuffles the playlist') .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), async execute(interaction, bot) { - await interaction.reply({ content: 'Reshuffling the playlist...', ephemeral: true }); - player.stop(); - return await shufflePlaylist(bot); + async function shuffleDetected(bot) { + await interaction.reply({ content: 'Reshuffling the playlist...', ephemeral: true }); + player.stop(); + await shufflePlaylist(bot); + } + return (shuffle === true) ? await shuffleDetected(bot) : await interaction.reply({ content: 'Shuffle mode is disabled, enable it on the configuration to access this command.', ephemeral: true }); } }; diff --git a/commands/status.js b/commands/status.js index d769cb5..2bb7703 100644 --- a/commands/status.js +++ b/commands/status.js @@ -21,7 +21,7 @@ import { SlashCommandBuilder } from '@discordjs/builders'; import { MessageEmbed } from 'discord.js'; -import { audio, audioArray, currentTrack, files, playerState } from '../AudioBackend.js'; +import { audio, currentTrack, files, playerState } from '../AudioBackend.js'; export default { data: new SlashCommandBuilder() @@ -31,7 +31,7 @@ export default { let audioID = currentTrack; audioID++; - let audioName = audioArray[audioID]; + let audioName = files[audioID]; if (audioName === undefined) { audioName = 'Playlist Finished'; } else { -- cgit v1.2.3