From 88e9419350b0d6c53d5b818a3f2ef5254b081102 Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Sun, 21 Jun 2020 17:31:36 +0200 Subject: [PATCH] :pencil: Add example for addToQueue method --- src/Player.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Player.js b/src/Player.js index 1bf1769..538e9ce 100644 --- a/src/Player.js +++ b/src/Player.js @@ -243,6 +243,28 @@ class Player { * @param {string} trackName The name of the track to add to the queue * @param {Discord.User?} requestedBy The user who requested the track * @returns {Promise} The added track + * + * @example + * client.on('message', async (message) => { + * + * const args = message.content.slice(settings.prefix.length).trim().split(/ +/g); + * const command = args.shift().toLowerCase(); + * + * if(command === 'play'){ + * let trackPlaying = client.player.isPlaying(message.guild.id); + * // If there's already a track being played + * if(trackPlaying){ + * // Add the track to the queue + * let track = await client.player.addToQueue(message.guild.id, args[0]); + * message.channel.send(`${track.name} added to queue!`); + * } else { + * // Else, play the track + * let track = await client.player.play(message.member.voice.channel, args[0]); + * message.channel.send(`Currently playing ${track.name}!`); + * } + * } + * + * }); */ addToQueue (guildID, trackName, requestedBy) { return new Promise((resolve, reject) => {