aboutsummaryrefslogtreecommitdiff
path: root/commands/control.js
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2022-03-28 16:05:12 -0400
committerAndrew Lee <alee14498@protonmail.com>2022-03-28 16:05:12 -0400
commit95870931e77a26a8d50ff3630bf387c923e61a2d (patch)
treecd3bfc550d8bc4af53451eebb480e51897a58771 /commands/control.js
parent1a99bec57db0fe7dddddaf833ec9c8300470ad1d (diff)
downloadDLAP-95870931e77a26a8d50ff3630bf387c923e61a2d.tar.gz
DLAP-95870931e77a26a8d50ff3630bf387c923e61a2d.tar.bz2
DLAP-95870931e77a26a8d50ff3630bf387c923e61a2d.zip
Fixed the leave button
Diffstat (limited to 'commands/control.js')
-rw-r--r--commands/control.js34
1 files changed, 11 insertions, 23 deletions
diff --git a/commands/control.js b/commands/control.js
index 42c168a..50a78e7 100644
--- a/commands/control.js
+++ b/commands/control.js
@@ -20,12 +20,8 @@
***************************************************************************/
import { SlashCommandBuilder } from '@discordjs/builders'
-import { getVoiceConnection } from "@discordjs/voice";
import { MessageEmbed, MessageActionRow, MessageButton } from 'discord.js'
-import { audio, player, playAudio } from '../AudioBackend.js'
-import fs from 'fs'
-
-let fileData;
+import { audio, player, playAudio, destroyAudio } from '../AudioBackend.js'
export default {
data: new SlashCommandBuilder()
@@ -61,32 +57,24 @@ export default {
const collector = interaction.channel.createMessageComponentCollector();
- collector.on('collect', async i => {
- if (i.customId === 'play') {
+ collector.on('collect', async ctlButton => {
+ if (ctlButton.customId === 'play') {
player.unpause();
- await i.reply({content:'Resuming music', ephemeral:true})
+ await ctlButton.reply({content:'Resuming music', ephemeral:true})
}
- if (i.customId === 'pause') {
+ if (ctlButton.customId === 'pause') {
player.pause();
- await i.reply({content:'Pausing music', ephemeral:true})
+ await ctlButton.reply({content:'Pausing music', ephemeral:true})
}
- if (i.customId === 'skip') {
+ if (ctlButton.customId === 'skip') {
player.pause();
- await i.reply({content:`Skipping \`${audio}\`...`, ephemeral:true})
+ await ctlButton.reply({content:`Skipping \`${audio}\`...`, ephemeral:true})
playAudio(bot);
}
- if (i.customId === 'leave') {
- await i.reply({content:'Leaving voice channel.', ephemeral:true})
+ if (ctlButton.customId === 'leave') {
+ await ctlButton.reply({content:'Leaving voice channel.', ephemeral:true})
console.log('Leaving voice channel...');
- fileData = "Now Playing: Nothing";
- fs.writeFile("now-playing.txt", fileData, (err) => {
- if (err)
- console.log(err);
- });
- audio = "Not Playing";
- player.stop();
- const connection = getVoiceConnection(interaction.guild.id);
- connection.destroy();
+ destroyAudio(interaction);
}
});