From 83e4c8679c656ecb352ddc34d5dced9518ba240a Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Thu, 7 Jul 2022 23:49:37 -0400 Subject: New shuffling system (not bug free yet); Tweaks and fixes on other commands --- commands/play.js | 10 +++++++--- commands/shutdown.js | 35 +++++++++++++++++++++++++++++++++++ commands/skip.js | 4 ++-- commands/status.js | 6 ++++-- commands/stop.js | 35 ----------------------------------- 5 files changed, 48 insertions(+), 42 deletions(-) create mode 100644 commands/shutdown.js delete mode 100644 commands/stop.js (limited to 'commands') diff --git a/commands/play.js b/commands/play.js index 2785288..d206c56 100644 --- a/commands/play.js +++ b/commands/play.js @@ -20,7 +20,7 @@ ***************************************************************************/ import { SlashCommandBuilder } from '@discordjs/builders' -import { isAudioStatePaused, inputAudio, audio, audioState, player } from '../AudioBackend.js' +import { isAudioStatePaused, inputAudio, audio, audioState, player, files } from '../AudioBackend.js' import { PermissionFlagsBits } from "discord-api-types/v10" export let integer; @@ -38,8 +38,12 @@ export default { async execute(interaction, bot) { integer = interaction.options.getInteger('int'); if (integer) { - await inputAudio(bot, integer); - return await interaction.reply({ content: `Now playing: ${audio}`, ephemeral: true }); + if (integer < files.length) { + await inputAudio(bot, integer); + return await interaction.reply({content:`Now playing: ${audio}`, ephemeral:true}); + } else { + return await interaction.reply({content:'Number is too big, choose a number that\'s less than ' + files.length + '.', ephemeral:true}) + } } if (isAudioStatePaused === true) { audioState(); diff --git a/commands/shutdown.js b/commands/shutdown.js new file mode 100644 index 0000000..4c32bc6 --- /dev/null +++ b/commands/shutdown.js @@ -0,0 +1,35 @@ +/************************************************************************** + * + * DLAP Bot: A Discord bot that plays local audio tracks. + * (C) Copyright 2022 + * Programmed by Andrew Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + ***************************************************************************/ + +import { SlashCommandBuilder } from '@discordjs/builders' +import { stopBot } from "../AudioBackend.js" +import { PermissionFlagsBits } from "discord-api-types/v10" + +export default { + data: new SlashCommandBuilder() + .setName('shutdown') + .setDescription('Powers off the bot') + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), + async execute(interaction, bot) { + await interaction.reply({ content: 'Powering off...', ephemeral: true}) + return await stopBot(bot, interaction); + }, +}; \ No newline at end of file diff --git a/commands/skip.js b/commands/skip.js index 3e1a836..3003ca0 100644 --- a/commands/skip.js +++ b/commands/skip.js @@ -20,7 +20,7 @@ ***************************************************************************/ import { SlashCommandBuilder } from '@discordjs/builders' -import { audio, player, searchAudio } from "../AudioBackend.js" +import { audio, player, nextAudio } from "../AudioBackend.js" import { PermissionFlagsBits } from "discord-api-types/v10" export default { @@ -31,6 +31,6 @@ export default { async execute(interaction, bot) { await interaction.reply({content:`Skipping ${audio}`, ephemeral:true}); player.stop(); - return await searchAudio(bot, interaction); + return await nextAudio(bot, interaction); }, }; \ No newline at end of file diff --git a/commands/status.js b/commands/status.js index d7012ce..e012239 100644 --- a/commands/status.js +++ b/commands/status.js @@ -21,18 +21,20 @@ import { SlashCommandBuilder } from '@discordjs/builders' import { MessageEmbed } from "discord.js" -import { audio, playerState } from "../AudioBackend.js" +import {audio, audioArray, currentTrack, playerState} from "../AudioBackend.js" export default { data: new SlashCommandBuilder() .setName('status') .setDescription('Checks what audio file is playing currently'), async execute(interaction, bot) { + let nextAudio = currentTrack + nextAudio++ let controlEmbed = new MessageEmbed() .setAuthor({name: `${bot.user.username} Status`, iconURL: bot.user.avatarURL()}) .addField('State', playerState) .addField('Currently Playing', audio) - //.addField('Next Music', '(a possible feature when queue system is implemented?)') + .addField('Next Music', audioArray[nextAudio]) .setColor('#0066ff') interaction.reply({embeds:[controlEmbed], ephemeral:true}) }, diff --git a/commands/stop.js b/commands/stop.js deleted file mode 100644 index c57301e..0000000 --- a/commands/stop.js +++ /dev/null @@ -1,35 +0,0 @@ -/************************************************************************** - * - * DLAP Bot: A Discord bot that plays local audio tracks. - * (C) Copyright 2022 - * Programmed by Andrew Lee - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - ***************************************************************************/ - -import { SlashCommandBuilder } from '@discordjs/builders' -import { stopBot } from "../AudioBackend.js" -import { PermissionFlagsBits } from "discord-api-types/v10" - -export default { - data: new SlashCommandBuilder() - .setName('stop') - .setDescription('Powers off the bot') - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), - async execute(interaction, bot) { - await interaction.reply({ content: 'Powering off...', ephemeral: true}) - return await stopBot(bot, interaction); - }, -}; \ No newline at end of file -- cgit v1.2.3