From a35aa5db7e9f5a47fd6fb8e2c731cb6b11a9b068 Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Sat, 18 Jan 2020 11:15:26 +0100 Subject: [PATCH] Update docs --- docs/Queue.html | 149 +++++++++++++++++++- docs/Song.html | 2 +- docs/Util.html | 350 ----------------------------------------------- docs/global.html | 27 +++- docs/index.html | 153 +++++++++++++++++---- 5 files changed, 301 insertions(+), 380 deletions(-) delete mode 100644 docs/Util.html diff --git a/docs/Queue.html b/docs/Queue.html index ac4be3b..faa46d3 100644 --- a/docs/Queue.html +++ b/docs/Queue.html @@ -24,7 +24,7 @@
@@ -444,6 +444,75 @@ + + + + + + + + + + + + + + + + +
Type:
+ + + + + + +
+ + + +
+

repeatMode :Boolean

+ + + + +
+

Whether the repeat mode is enabled.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + @@ -764,6 +833,84 @@ +
+ + + +

channelEmpty

+ + + + + +
+

Emitted when the voice channel is empty.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
diff --git a/docs/Song.html b/docs/Song.html index 22960f2..02c9e10 100644 --- a/docs/Song.html +++ b/docs/Song.html @@ -24,7 +24,7 @@
diff --git a/docs/Util.html b/docs/Util.html deleted file mode 100644 index bc47cdc..0000000 --- a/docs/Util.html +++ /dev/null @@ -1,350 +0,0 @@ - - - - - - Util - Documentation - - - - - - - - - - - - - - - - - -
- -

Util

- - - - - - - -
- -
- -

- Util -

- -

Utilities.

- - -
- -
-
- - -
- - -

Constructor

- - -

new Util()

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - -

Methods

- - - -
- - - -

(static) getFirstYoutubeResult(search, SYA) → {Promise.<Video>}

- - - - - -
-

Gets the first youtube results for your search.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
search - - -string - - - - -

The name of the video or the video URL.

- -
SYA - - -Youtube - - - - -

The Simple Youtube API Client.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise.<Video> - - -
-
- - - -
- - - -
- - - - - - -
- -
- - - - -
- -
- - - - - - - \ No newline at end of file diff --git a/docs/global.html b/docs/global.html index 458904b..6b1cdad 100644 --- a/docs/global.html +++ b/docs/global.html @@ -24,7 +24,7 @@
@@ -202,6 +202,31 @@ + + + + leaveOnEmpty + + + + + +Boolean + + + + + + + + + +

Whether the bot should leave the voice channel if there is no more member in it.

+ + + + + diff --git a/docs/index.html b/docs/index.html index 053133a..5e0a501 100644 --- a/docs/index.html +++ b/docs/index.html @@ -24,7 +24,7 @@
@@ -54,23 +54,6 @@ patreonBadge

Note: this module uses recent discordjs features and requires discord.js version 12.

Discord Player is a powerful Node.js module that allows you to easily implement music commands. Everything is customizable, and everything is done to simplify your work without limiting you!

-

Installation

npm install --save discord-player
 
@@ -86,7 +69,7 @@ settings = { token: "Your Discord Token" }; -const { Player } = require('discord-player'); +const { Player } = require("discord-player"); // Create a new Player (Youtube API key is your Youtube Data v3 key) const player = new Player(client, "YOUTUBE API KEY"); // To easily access the player @@ -100,9 +83,56 @@ client.login(settings.token);

You can pass a third parameter when instantiating the class Player: the options object:
options.leaveOnEnd: whether the bot should leave the voice channel when there is no more song in the queue.
-options.leaveOnStop: whether the bot should leave the voice channel when the stop() function is used.

+options.leaveOnStop: whether the bot should leave the voice channel when the stop() function is used.
+options.leaveOnEmpty: whether the bot should leave the voice channel if there is no more member in it.

+

Features Overview

+

You need to init the guild queue using the play() function, then you are able to manage the queue using the following functions:

+
// Play a song in the voice channel and init the guild queue
+client.player.play(voiceChannel, songName);
+
+// Add a song to the queue
+client.player.addToQueue(guildID, songName);
+// Clear the queue
+client.player.clearQueue(guildID);
+// Get the queue
+client.player.getQueue(guildID);
+// Skip the current song
+client.player.skip(guildID);
+
+
+// Pause
+client.player.pause(guildID);
+// Resume
+client.player.resume(guildID);
+// Stop
+client.player.stop(guildID);
+
+// Check if music is playing in a guild
+client.player.isPlaying(guildID);
+// Get the currently playing song
+client.player.nowPlaying(guildID);
+
+
+// Current song will be repeated indefinitely
+client.player.setRepeatMode(true);
+// Current song will no longer be repeated indefinitely
+client.player.setRepeatMode(false);
+
+

Event messages

+
client.player.getQueue(guildID)
+.on('end', () => {
+    message.channel.send('There is no more music in the queue!');
+})
+.on('songChanged', (oldSong, newSong) => {
+    message.channel.send(`Now playing ${newSong.name}...`);
+})
+.on('channelEmpty', () => {
+    message.channel.send('Stop playing, there is no more member in the voice channel...');
+});
+
+

Examples

Play

-

To play a song, use the client.manager.play() function.

+

To play a song, use the client.player.play() function.

Usage:

client.player.play(voiceChannel, songName);
 
@@ -122,7 +152,7 @@ client.login(settings.token);

Pause

-

To pause the current song, use the client.manager.pause() function.

+

To pause the current song, use the client.player.pause() function.

Usage:

client.player.pause(guildID);
 
@@ -140,7 +170,7 @@ client.login(settings.token); });

Resume

-

To resume the current song, use the client.manager.resume() function.

+

To resume the current song, use the client.player.resume() function.

Usage:

client.player.resume(guildID);
 
@@ -158,7 +188,7 @@ client.login(settings.token); });

Stop

-

To stop the music, use the client.manager.stop() function.

+

To stop the music, use the client.player.stop() function.

Usage:

client.player.stop(guildID);
 
@@ -176,7 +206,7 @@ client.login(settings.token); });

SetVolume

-

To update the volume, use the client.manager.setVolume() function.

+

To update the volume, use the client.player.setVolume() function.

Usage:

client.player.setVolume(guildID, percent);
 
@@ -267,6 +297,71 @@ client.login(settings.token); * #4 - Circles | Post Malone */ +}); + +

Skip

+

To skip the current song, use the client.player.skip() function.

+

Usage:

+
client.player.skip(guildID);
+
+

Example:

+
client.on('message', async (message) => {
+
+    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
+    const command = args.shift().toLowerCase();
+
+    if(command === 'skip'){
+        let song = await client.player.skip(message.guild.id);
+        message.channel.send(`${song.name} skipped!`);
+    }
+
+});
+
+

Now Playing

+

To get the currently playing song, use the client.player.nowPlaying() function.

+

Usage:

+
client.player.nowPlaying(guildID);
+
+

Example:

+
client.on('message', async (message) => {
+
+    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
+    const command = args.shift().toLowerCase();
+
+    if(command === 'now-playing'){
+        let song = await client.player.nowPlaying(message.guild.id);
+        message.channel.send(`Currently playing ${song.name}...`);
+    }
+
+});
+
+

Repeat

+

To repeat the current song, use the client.player.setRepeatMode() function.

+

Usage:

+
client.player.setRepeatMode(boolean);
+
+

Example:

+
client.on('message', async (message) => {
+
+    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
+    const command = args.shift().toLowerCase();
+
+    if(command === 'enable-repeat'){
+        // Enable repeat mode
+        client.player.setRepeatMode(true);
+        // Get the current song
+        let song = await client.player.nowPlaying(message.guild.id);
+        message.channel.send(`${song.name} will be repeated indefinitely!`);
+    }
+
+    if(command === 'disable-repeat'){
+        // Disable repeat mode
+        client.player.setRepeatMode(false);
+        // Get the current song
+        let song = await client.player.nowPlaying(message.guild.id);
+        message.channel.send(`${song.name}  will no longer be repeated indefinitely!`);
+    }
+
 });
 

Info Messages

@@ -281,8 +376,12 @@ client.login(settings.token); song.queue.on('end', () => { message.channel.send('The queue is empty, please add new songs!'); }); - song.queue.on('songChanged', (oldSong, newSong) => { - message.channel.send(`Now playing ${newSong}...`); + song.queue.on('songChanged', (oldSong, newSong, skipped, repeatMode) => { + if(repeatMode){ + message.channel.send(`Playing ${newSong} again...`); + } else { + message.channel.send(`Now playing ${newSong}...`); + } }); }