feat: add requestedBy for song
This commit is contained in:
parent
fd5821e977
commit
4509290bc1
2 changed files with 8 additions and 5 deletions
|
@ -91,9 +91,10 @@ class Player {
|
||||||
* Plays a song in a voice channel.
|
* Plays a song in a voice channel.
|
||||||
* @param {voiceChannel} voiceChannel The voice channel in which the song will be played.
|
* @param {voiceChannel} voiceChannel The voice channel in which the song will be played.
|
||||||
* @param {string} songName The name of the song to play.
|
* @param {string} songName The name of the song to play.
|
||||||
|
* @param {User} requestedBy The user who requested the song.
|
||||||
* @returns {Promise<Song>}
|
* @returns {Promise<Song>}
|
||||||
*/
|
*/
|
||||||
play(voiceChannel, songName) {
|
play(voiceChannel, songName, requestedBy) {
|
||||||
this.queues = this.queues.filter((g) => g.guildID !== voiceChannel.id);
|
this.queues = this.queues.filter((g) => g.guildID !== voiceChannel.id);
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
if(!voiceChannel || typeof voiceChannel !== "object") return reject("voiceChannel must be type of VoiceChannel. value="+voiceChannel);
|
if(!voiceChannel || typeof voiceChannel !== "object") return reject("voiceChannel must be type of VoiceChannel. value="+voiceChannel);
|
||||||
|
@ -106,7 +107,7 @@ class Player {
|
||||||
// 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 = connection;
|
||||||
let song = new Song(video, queue);
|
let song = new Song(video, queue, requestedBy);
|
||||||
queue.songs.push(song);
|
queue.songs.push(song);
|
||||||
// Add the queue to the list
|
// Add the queue to the list
|
||||||
this.queues.push(queue);
|
this.queues.push(queue);
|
||||||
|
@ -205,9 +206,10 @@ class Player {
|
||||||
* Adds a song to the guild queue.
|
* Adds a song to the guild queue.
|
||||||
* @param {string} guildID
|
* @param {string} guildID
|
||||||
* @param {string} songName The name of the song to add to the queue.
|
* @param {string} songName The name of the song to add to the queue.
|
||||||
|
* @param {User} requestedBy The user who requested the song.
|
||||||
* @returns {Promise<Song>}
|
* @returns {Promise<Song>}
|
||||||
*/
|
*/
|
||||||
addToQueue(guildID, songName){
|
addToQueue(guildID, songName, requestedBy){
|
||||||
return new Promise(async(resolve, reject) => {
|
return new Promise(async(resolve, reject) => {
|
||||||
// Gets guild queue
|
// Gets guild queue
|
||||||
let queue = this.queues.find((g) => g.guildID === guildID);
|
let queue = this.queues.find((g) => g.guildID === guildID);
|
||||||
|
@ -215,7 +217,7 @@ class Player {
|
||||||
// Searches the song
|
// Searches the song
|
||||||
let video = await Util.getFirstYoutubeResult(songName, this.SYA).catch(() => {});
|
let video = await Util.getFirstYoutubeResult(songName, this.SYA).catch(() => {});
|
||||||
if(!video) return reject('Song not found');
|
if(!video) return reject('Song not found');
|
||||||
let song = new Song(video, queue);
|
let song = new Song(video, queue, requestedBy);
|
||||||
// Updates queue
|
// Updates queue
|
||||||
queue.songs.push(song);
|
queue.songs.push(song);
|
||||||
// Resolves the song
|
// Resolves the song
|
||||||
|
@ -330,6 +332,7 @@ class Player {
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start playing songs in a guild.
|
* Start playing songs in a guild.
|
||||||
* @ignore
|
* @ignore
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Song {
|
||||||
*/
|
*/
|
||||||
this.thumbnail = video.raw.snippet.thumbnails.default.url;
|
this.thumbnail = video.raw.snippet.thumbnails.default.url;
|
||||||
/**
|
/**
|
||||||
* The queue in which the song is
|
* The queue in which the song is.
|
||||||
* @type {Queue}
|
* @type {Queue}
|
||||||
*/
|
*/
|
||||||
this.queue = queue;
|
this.queue = queue;
|
||||||
|
|
Loading…
Reference in a new issue