From 86ae74f2e39b33913ccfa869f4125ef42464b662 Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Sun, 12 Jan 2020 19:13:54 +0100 Subject: [PATCH] play: check if bot is already connected --- src/Player.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Player.js b/src/Player.js index 01091dd..2fd6cca 100644 --- a/src/Player.js +++ b/src/Player.js @@ -95,11 +95,13 @@ class Player { // Searches the song let video = await Util.getFirstYoutubeResult(songName, this.SYA); if(!video) reject('Song not found'); - // Joins the voice channel - let connection = await voiceChannel.join(); + if(!voiceChannel.guild.me.voice.channel || (voiceChannel.guild.me.voice.channel.id !== voiceChannel.id)){ + // Joins the voice channel + await voiceChannel.join(); + } // Creates a new guild with data let queue = new Queue(voiceChannel.guild.id); - queue.connection = connection; + queue.connection = voiceChannel.guild.me.voice.connection; let song = new Song(video, queue); queue.songs.push(song); // Add the queue to the list