play: check if bot is already connected

This commit is contained in:
Androz2091 2020-01-12 19:13:54 +01:00
parent b74152f7b9
commit 86ae74f2e3

View file

@ -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