play: check if bot is already connected
This commit is contained in:
parent
b74152f7b9
commit
86ae74f2e3
1 changed files with 5 additions and 3 deletions
|
@ -95,11 +95,13 @@ class Player {
|
||||||
// Searches the song
|
// Searches the song
|
||||||
let video = await Util.getFirstYoutubeResult(songName, this.SYA);
|
let video = await Util.getFirstYoutubeResult(songName, this.SYA);
|
||||||
if(!video) reject('Song not found');
|
if(!video) reject('Song not found');
|
||||||
// Joins the voice channel
|
if(!voiceChannel.guild.me.voice.channel || (voiceChannel.guild.me.voice.channel.id !== voiceChannel.id)){
|
||||||
let connection = await voiceChannel.join();
|
// Joins the voice channel
|
||||||
|
await voiceChannel.join();
|
||||||
|
}
|
||||||
// Creates a new guild with data
|
// Creates a new guild with data
|
||||||
let queue = new Queue(voiceChannel.guild.id);
|
let queue = new Queue(voiceChannel.guild.id);
|
||||||
queue.connection = connection;
|
queue.connection = voiceChannel.guild.me.voice.connection;
|
||||||
let song = new Song(video, queue);
|
let song = new Song(video, queue);
|
||||||
queue.songs.push(song);
|
queue.songs.push(song);
|
||||||
// Add the queue to the list
|
// Add the queue to the list
|
||||||
|
|
Loading…
Reference in a new issue