diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2020-07-21 17:13:52 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2020-07-21 17:13:52 -0400 |
| commit | b42e97519c5157c70cbb8ef0a16e66b204f57284 (patch) | |
| tree | e2d73330203ff7ad72e975a6a0d0edee70215575 | |
| parent | 7f8432ee32e10fe6e69a5a53f738547b81d4791a (diff) | |
| download | DLAP-b42e97519c5157c70cbb8ef0a16e66b204f57284.tar.gz DLAP-b42e97519c5157c70cbb8ef0a16e66b204f57284.tar.bz2 DLAP-b42e97519c5157c70cbb8ef0a16e66b204f57284.zip | |
Made some changes with the voice channel variable
| -rw-r--r-- | bot.js | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -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') { |
