aboutsummaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2022-03-29 20:41:38 -0400
committerAndrew Lee <alee14498@protonmail.com>2022-03-29 20:41:38 -0400
commitfd89e36490da711ba611c1f7c8dda93a3de054f0 (patch)
treee8c1114add718665c75bb90e7af90a9f38101815 /commands
parent84b7017c7016aea12339ec4a3ef2ba1bf0fb3872 (diff)
downloadDLAP-fd89e36490da711ba611c1f7c8dda93a3de054f0.tar.gz
DLAP-fd89e36490da711ba611c1f7c8dda93a3de054f0.tar.bz2
DLAP-fd89e36490da711ba611c1f7c8dda93a3de054f0.zip
New command; Every Discord interation is async
Diffstat (limited to 'commands')
-rw-r--r--commands/about.js2
-rw-r--r--commands/control.js16
-rw-r--r--commands/help.js4
-rw-r--r--commands/join.js6
-rw-r--r--commands/list.js2
-rw-r--r--commands/ping.js2
-rw-r--r--commands/play.js43
-rw-r--r--commands/stop.js4
8 files changed, 61 insertions, 18 deletions
diff --git a/commands/about.js b/commands/about.js
index 8177d81..55ef011 100644
--- a/commands/about.js
+++ b/commands/about.js
@@ -46,6 +46,6 @@ export default {
.setURL('https://github.com/Alee14/DLMP3'),
);
- return interaction.reply({ embeds:[aboutEmbed], components:[srcOrig] });
+ return await interaction.reply({ embeds:[aboutEmbed], components:[srcOrig] });
},
}; \ No newline at end of file
diff --git a/commands/control.js b/commands/control.js
index 7f5e9cb..f221898 100644
--- a/commands/control.js
+++ b/commands/control.js
@@ -21,7 +21,7 @@
import { SlashCommandBuilder } from '@discordjs/builders'
import { MessageEmbed, MessageActionRow, MessageButton } from 'discord.js'
-import { audio, player, playAudio, destroyAudio, voiceInit, stopBot } from '../AudioBackend.js'
+import {audio, player, destroyAudio, voiceInit, stopBot, searchAudio} from '../AudioBackend.js'
import config from '../config.json' assert {type: 'json'}
export let controlEmbed
@@ -60,7 +60,7 @@ export default {
new MessageButton()
.setStyle('SECONDARY')
.setLabel('>>')
- .setCustomId('more'),
+ .setCustomId('next'),
);
const controlButtons2 = new MessageActionRow()
@@ -68,7 +68,7 @@ export default {
new MessageButton()
.setStyle('SECONDARY')
.setLabel('<<')
- .setCustomId('less'),
+ .setCustomId('back'),
new MessageButton()
.setStyle('DANGER')
.setLabel('Leave')
@@ -86,7 +86,7 @@ export default {
collector.on('collect', async ctlButton => {
if (ctlButton.customId === 'join') {
await ctlButton.reply({content:'Joining voice channel', ephemeral:true})
- voiceInit(bot);
+ await voiceInit(bot);
}
if (ctlButton.customId === 'play') {
await ctlButton.reply({content:'Resuming music', ephemeral:true})
@@ -99,12 +99,12 @@ export default {
if (ctlButton.customId === 'skip') {
await ctlButton.reply({content:`Skipping \`${audio}\`...`, ephemeral:true})
player.pause();
- playAudio(bot);
+ await searchAudio(bot);
}
- if (ctlButton.customId === 'more') {
+ if (ctlButton.customId === 'next') {
await interaction.editReply({ components: [controlButtons2] });
}
- if (ctlButton.customId === 'less') {
+ if (ctlButton.customId === 'back') {
await interaction.editReply({ components: [controlButtons] });
}
if (ctlButton.customId === 'leave') {
@@ -120,6 +120,6 @@ export default {
collector.on('end', collected => console.log(`Collected ${collected.size} items`));
- return interaction.reply({embeds:[controlEmbed], components:[controlButtons]});
+ return await interaction.reply({embeds:[controlEmbed], components:[controlButtons]});
},
}; \ No newline at end of file
diff --git a/commands/help.js b/commands/help.js
index b1ba51f..e23b105 100644
--- a/commands/help.js
+++ b/commands/help.js
@@ -20,7 +20,7 @@
***************************************************************************/
import { SlashCommandBuilder } from '@discordjs/builders'
-import { MessageEmbed } from "discord.js";
+import { MessageEmbed } from 'discord.js';
import { audio } from '../AudioBackend.js'
export default {
@@ -36,6 +36,6 @@ export default {
.setFooter({text:'© Copyright 2020-2022 Andrew Lee. Licensed with GPL-3.0.'})
.setColor('#0066ff')
- return interaction.reply({ embeds: [helpEmbed]});
+ return await interaction.reply({ embeds: [helpEmbed]});
},
}; \ No newline at end of file
diff --git a/commands/join.js b/commands/join.js
index 8778aae..72aae2e 100644
--- a/commands/join.js
+++ b/commands/join.js
@@ -20,7 +20,7 @@
***************************************************************************/
import { SlashCommandBuilder } from '@discordjs/builders'
-import { voiceInit } from "../AudioBackend.js";
+import { voiceInit } from '../AudioBackend.js';
import config from '../config.json' assert {type: 'json'}
export default {
@@ -29,7 +29,7 @@ export default {
.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('Joining voice channel')
- voiceInit(bot);
+ await interaction.reply({ content: 'Joining voice channel', ephemeral: true })
+ return await voiceInit(bot);
},
}; \ No newline at end of file
diff --git a/commands/list.js b/commands/list.js
index 4ec7156..673b779 100644
--- a/commands/list.js
+++ b/commands/list.js
@@ -29,7 +29,7 @@ export default {
.setName('list')
.setDescription('Lists the available audio tracks'),
async execute(interaction) {
- interaction.reply('Listing the available audio tracks...');
+ await interaction.reply('Listing the available audio tracks...');
fs.readdirSync(musicFolder).forEach(file => {
console.log(file);
});
diff --git a/commands/ping.js b/commands/ping.js
index cbf5370..14071ac 100644
--- a/commands/ping.js
+++ b/commands/ping.js
@@ -26,6 +26,6 @@ export default {
.setName('ping')
.setDescription('Pong!'),
async execute(interaction) {
- return interaction.reply('Pong!');
+ return await interaction.reply('Pong!');
},
}; \ No newline at end of file
diff --git a/commands/play.js b/commands/play.js
new file mode 100644
index 0000000..df5be96
--- /dev/null
+++ b/commands/play.js
@@ -0,0 +1,43 @@
+/**************************************************************************
+ *
+ * DLMP3 Bot: A Discord bot that plays local MP3 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 { inputAudio, audio } from '../AudioBackend.js'
+import config from '../config.json' assert {type: 'json'}
+
+export let integer;
+
+export default {
+ data: new SlashCommandBuilder()
+ .setName('play')
+ .setDescription('Plays the audio by number')
+ .addIntegerOption(option =>
+ option.setName('int')
+ .setDescription('Input a number for the selection for the audio file.')
+ .setRequired(true),
+ ),
+ 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});
+ },
+}; \ No newline at end of file
diff --git a/commands/stop.js b/commands/stop.js
index f1bd8eb..c753a1b 100644
--- a/commands/stop.js
+++ b/commands/stop.js
@@ -29,7 +29,7 @@ export default {
.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('Powering off...')
- await stopBot(bot, interaction);
+ await interaction.reply({ content: 'Powering off...', ephemeral: true})
+ return await stopBot(bot, interaction);
},
}; \ No newline at end of file