diff options
Diffstat (limited to 'commands')
| -rw-r--r-- | commands/help.js | 41 | ||||
| -rw-r--r-- | commands/join.js | 1 | ||||
| -rw-r--r-- | commands/pause.js | 14 | ||||
| -rw-r--r-- | commands/play.js | 17 | ||||
| -rw-r--r-- | commands/skip.js | 4 | ||||
| -rw-r--r-- | commands/stop.js | 1 |
6 files changed, 24 insertions, 54 deletions
diff --git a/commands/help.js b/commands/help.js deleted file mode 100644 index ec0283c..0000000 --- a/commands/help.js +++ /dev/null @@ -1,41 +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 <https://www.gnu.org/licenses/>. - * - ***************************************************************************/ - -import { SlashCommandBuilder } from '@discordjs/builders' -import { MessageEmbed } from 'discord.js' -import { audio } from '../AudioBackend.js' - -export default { - data: new SlashCommandBuilder() - .setName('help') - .setDescription('Displays commands'), - async execute(interaction, bot) { - const helpEmbed = new MessageEmbed() - .setAuthor({name:`${bot.user.username} Help`, iconURL:bot.user.avatarURL()}) - .setDescription(`Currently playing \`${audio}\``) - .addField('Public Commands', `/help\n/ping\n/about\n`, true) - .addField('Bot Owner Only', `/join\n/control\n/stop\n`, true) - .setFooter({text:'© Copyright 2020-2022 Andrew Lee'}) - .setColor('#0066ff') - - return await interaction.reply({ embeds: [helpEmbed] }); - }, -};
\ No newline at end of file diff --git a/commands/join.js b/commands/join.js index 0de2f14..8ede21a 100644 --- a/commands/join.js +++ b/commands/join.js @@ -28,7 +28,6 @@ export default { .setName('join') .setDescription('Joins voice chat.'), async execute(interaction, bot) { - if (![config.botOwner].includes(interaction.user.id)) return await interaction.reply({ content: "You do not have permissions to execute this command.", ephemeral: true }); await interaction.reply({ content: 'Joining voice channel', ephemeral: true }) return await voiceInit(bot); }, diff --git a/commands/pause.js b/commands/pause.js index c0edeeb..7615573 100644 --- a/commands/pause.js +++ b/commands/pause.js @@ -21,15 +21,19 @@ import { SlashCommandBuilder } from '@discordjs/builders' import config from '../config.json' assert {type: 'json'} - -export let integer; +import {audioState, isAudioStatePaused, player} from "../AudioBackend.js"; export default { data: new SlashCommandBuilder() .setName('pause') .setDescription('Pauses the player'), - async execute(interaction, bot) { - if (![config.botOwner].includes(interaction.user.id)) return await interaction.reply({ content: "You do not have permissions to execute this command.", ephemeral: true }); - + async execute(interaction) { + if (isAudioStatePaused === false) { + audioState(); + player.pause(); + return await interaction.reply({content:'Pausing music', ephemeral:true}); + } else { + return await interaction.reply({content:"Music is already paused", ephemeral:true}) + } }, };
\ No newline at end of file diff --git a/commands/play.js b/commands/play.js index a6d3453..2a5a385 100644 --- a/commands/play.js +++ b/commands/play.js @@ -20,7 +20,7 @@ ***************************************************************************/ import { SlashCommandBuilder } from '@discordjs/builders' -import { inputAudio, audio } from '../AudioBackend.js' +import { isAudioStatePaused, inputAudio, audio, audioState, player } from '../AudioBackend.js' import config from '../config.json' assert {type: 'json'} export let integer; @@ -33,10 +33,19 @@ export default { option.setName('int') .setDescription('Input a number for the selection for the audio file.'), ), + async execute(interaction, bot) { - if (![config.botOwner].includes(interaction.user.id)) return await interaction.reply({ content: "You do not have permissions to execute this command.", ephemeral: true }); integer = interaction.options.getInteger('int'); - await inputAudio(bot, integer); - return await interaction.reply({ content: `Now playing: ${audio}`, ephemeral: true }); + if (integer) { + await inputAudio(bot, integer); + return await interaction.reply({ content: `Now playing: ${audio}`, ephemeral: true }); + } + if (isAudioStatePaused === true) { + audioState(); + player.unpause(); + return await interaction.reply({content:'Resuming music', ephemeral:true}); + } else { + return await interaction.reply({content:"Music is already playing", ephemeral:true}) + } }, };
\ No newline at end of file diff --git a/commands/skip.js b/commands/skip.js index 4860209..a49b904 100644 --- a/commands/skip.js +++ b/commands/skip.js @@ -27,8 +27,8 @@ export default { .setName('skip') .setDescription('Skips the track'), async execute(interaction, bot) { + await interaction.reply({content:`Skipping ${audio}`, ephemeral:true}); player.stop(); - await searchAudio(bot, interaction); - return await interaction.reply({content:`Skipping ${audio}`, ephemeral:true}); + return await searchAudio(bot, interaction); }, };
\ No newline at end of file diff --git a/commands/stop.js b/commands/stop.js index ced8fe5..b3997e2 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -28,7 +28,6 @@ export default { .setName('stop') .setDescription('Powers off the bot'), async execute(interaction, bot) { - if (![config.botOwner].includes(interaction.user.id)) return await interaction.reply({ content: "You do not have permissions to execute this command.", ephemeral: true }); await interaction.reply({ content: 'Powering off...', ephemeral: true}) return await stopBot(bot, interaction); }, |
