aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-07-21 17:13:52 -0400
committerAndrew Lee <alee14498@protonmail.com>2020-07-21 17:13:52 -0400
commitb42e97519c5157c70cbb8ef0a16e66b204f57284 (patch)
treee2d73330203ff7ad72e975a6a0d0edee70215575
parent7f8432ee32e10fe6e69a5a53f738547b81d4791a (diff)
downloadDLAP-b42e97519c5157c70cbb8ef0a16e66b204f57284.tar.gz
DLAP-b42e97519c5157c70cbb8ef0a16e66b204f57284.tar.bz2
DLAP-b42e97519c5157c70cbb8ef0a16e66b204f57284.zip
Made some changes with the voice channel variable
-rw-r--r--bot.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/bot.js b/bot.js
index e36c90f..736bcb5 100644
--- a/bot.js
+++ b/bot.js
@@ -24,14 +24,15 @@ const client = new Discord.Client();
const config = require('./config.json');
let dispatcher;
let audio;
+let voiceChannel;
client.login(config.token);
function playAudio() {
- const channel = client.channels.cache.get(config.voiceChannel);
- if (!channel) return console.error('The voice channel does not exist!\n(Have you looked at your configuration?)');
+ voiceChannel = client.channels.cache.get(config.voiceChannel);
+ if (!voiceChannel) return console.error('The voice channel does not exist!\n(Have you looked at your configuration?)');
- channel.join().then(connection => {
+ voiceChannel.join().then(connection => {
let files = fs.readdirSync('./music');
while (true) {
@@ -130,12 +131,12 @@ client.on('message', async msg => {
}
if (command == 'leave') {
- const channel = client.channels.cache.get(config.voiceChannel);
- if (!channel) return console.error('The voice channel does not exist!\n(Have you looked at your configuration?)');
+ voiceChannel = client.channels.cache.get(config.voiceChannel);
+ if (!voiceChannel) return console.error('The voice channel does not exist!\n(Have you looked at your configuration?)');
msg.reply('Leaving voice channel.');
console.log('Leaving voice channel.');
dispatcher.destroy();
- channel.leave();
+ voiceChannel.leave();
}
if (command == 'stop') {