discord-player 6.6.3-dev.0 → 6.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -18
- package/dist/index.d.ts +2524 -2466
- package/dist/index.js +1361 -117
- package/dist/index.mjs +4 -0
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@ Discord Player is a robust framework for developing Discord Music bots using Jav
|
|
|
23
23
|
- Built-in stats tracker
|
|
24
24
|
- Offers easy debugging methods
|
|
25
25
|
- Out-of-the-box voice states handling
|
|
26
|
+
- IP Rotation support
|
|
26
27
|
|
|
27
28
|
## Installation
|
|
28
29
|
|
|
@@ -41,17 +42,33 @@ $ npm install --save @discord-player/extractor # extractors provider
|
|
|
41
42
|
|
|
42
43
|
#### Opus Library
|
|
43
44
|
|
|
44
|
-
Since Discord only accepts opus packets, you need to install the opus library.
|
|
45
|
+
Since Discord only accepts opus packets, you need to install the opus library. Discord Player supports multiple opus libraries, such as:
|
|
46
|
+
|
|
47
|
+
- [mediaplex](https://npmjs.com/mediaplex)
|
|
48
|
+
- [@discordjs/opus](https://npmjs.com/@discordjs/opus)
|
|
49
|
+
- [opusscript](https://npmjs.com/opusscript)
|
|
50
|
+
- [@evan/opus](https://npmjs.com/@evan/opus)
|
|
51
|
+
- [node-opus](https://npmjs.com/node-opus)
|
|
52
|
+
|
|
53
|
+
Among these, mediaplex is the recommended library as it adds more functionalities to discord-player than just libopus interface. You can install opus libraries by running:
|
|
45
54
|
|
|
46
55
|
```bash
|
|
56
|
+
$ npm install --save mediaplex
|
|
57
|
+
# or
|
|
47
58
|
$ npm install --save @discordjs/opus
|
|
48
59
|
# or
|
|
49
60
|
$ npm install --save opusscript
|
|
61
|
+
# or
|
|
62
|
+
$ npm install --save @evan/opus
|
|
63
|
+
# or
|
|
64
|
+
$ npm install --save node-opus
|
|
50
65
|
```
|
|
51
66
|
|
|
52
67
|
#### FFmpeg or Avconv
|
|
53
68
|
|
|
54
|
-
FFmpeg or Avconv is required for media transcoding. You can obtain it from [https://ffmpeg.org](https://ffmpeg.org) or
|
|
69
|
+
FFmpeg or Avconv is required for media transcoding. You can obtain it from [https://ffmpeg.org](https://ffmpeg.org) or via npm.
|
|
70
|
+
|
|
71
|
+
> We do not recommend installing ffmpeg via npm because binaries pulled from npm is known to be unstable. It is recommended to install it from the official source.
|
|
55
72
|
|
|
56
73
|
```bash
|
|
57
74
|
$ npm install --save ffmpeg-static
|
|
@@ -67,30 +84,31 @@ $ npm install --save ffmpeg-binaries
|
|
|
67
84
|
|
|
68
85
|
#### Streaming Library
|
|
69
86
|
|
|
70
|
-
If you want to add support for YouTube playback, you need to install a streaming library.
|
|
87
|
+
YouTube streaming is not supported without installing one of the following package. If you want to add support for YouTube playback, you need to install a streaming library. This step is not needed if you do not plan on using youtube source.
|
|
71
88
|
|
|
72
89
|
```bash
|
|
73
|
-
$ npm install --save
|
|
90
|
+
$ npm install --save youtube-ext
|
|
74
91
|
# or
|
|
75
92
|
$ npm install --save play-dl
|
|
76
93
|
# or
|
|
77
94
|
$ npm install --save @distube/ytdl-core
|
|
78
95
|
# or
|
|
79
96
|
$ npm install --save yt-stream
|
|
97
|
+
# or
|
|
98
|
+
$ npm install --save ytdl-core
|
|
80
99
|
```
|
|
81
100
|
|
|
101
|
+
We recommend using `youtube-ext` for better performance.
|
|
102
|
+
|
|
82
103
|
Once you have completed these installations, let's proceed with writing a simple music bot.
|
|
83
104
|
|
|
84
105
|
### Setup
|
|
85
106
|
|
|
86
107
|
Let's create a main player instance. This instance handles and keeps track of all the queues and its components.
|
|
87
108
|
|
|
88
|
-
```js
|
|
109
|
+
```js index.js
|
|
89
110
|
const { Player } = require('discord-player');
|
|
90
111
|
|
|
91
|
-
// get some extractors if you want to handpick sources
|
|
92
|
-
const { SpotifyExtractor, SoundCloudExtractor } = require('@discord-player/extractor');
|
|
93
|
-
|
|
94
112
|
const client = new Discord.Client({
|
|
95
113
|
// Make sure you have 'GuildVoiceStates' intent enabled
|
|
96
114
|
intents: ['GuildVoiceStates' /* Other intents */]
|
|
@@ -99,17 +117,13 @@ const client = new Discord.Client({
|
|
|
99
117
|
// this is the entrypoint for discord-player based application
|
|
100
118
|
const player = new Player(client);
|
|
101
119
|
|
|
102
|
-
//
|
|
103
|
-
await player.extractors.loadDefault();
|
|
104
|
-
|
|
105
|
-
// If you dont want to use all of the extractors and register only the required ones manually, use
|
|
106
|
-
await player.extractors.register(SpotifyExtractor, {});
|
|
107
|
-
await player.extractors.register(SoundCloudExtractor, {});
|
|
120
|
+
// Now, lets load all the default extractors, except 'YouTubeExtractor'. You can remove the filter if you want to load all the extractors.
|
|
121
|
+
await player.extractors.loadDefault((ext) => ext !== 'YouTubeExtractor');
|
|
108
122
|
```
|
|
109
123
|
|
|
110
124
|
Discord Player is mostly events based. It emits different events based on the context and actions. Let's add a basic event listener to notify the user when a track starts to play:
|
|
111
125
|
|
|
112
|
-
```js
|
|
126
|
+
```js index.js
|
|
113
127
|
// this event is emitted whenever discord-player starts to play a track
|
|
114
128
|
player.events.on('playerStart', (queue, track) => {
|
|
115
129
|
// we will later define queue.metadata object while creating the queue
|
|
@@ -117,10 +131,13 @@ player.events.on('playerStart', (queue, track) => {
|
|
|
117
131
|
});
|
|
118
132
|
```
|
|
119
133
|
|
|
120
|
-
Let's move on to the command part. You can define the command as per your requirements. We will only focus on the command
|
|
134
|
+
Let's move on to the command part. You can define the command as per your requirements. We will only focus on the command part:
|
|
135
|
+
|
|
136
|
+
```js play.js
|
|
137
|
+
const { useMainPlayer } = require('discord-player');
|
|
121
138
|
|
|
122
|
-
|
|
123
|
-
|
|
139
|
+
export async function execute(interaction) {
|
|
140
|
+
const player = useMainPlayer();
|
|
124
141
|
const channel = interaction.member.voice.channel;
|
|
125
142
|
if (!channel) return interaction.reply('You are not connected to a voice channel!'); // make sure we have a voice channel
|
|
126
143
|
const query = interaction.options.getString('query', true); // we need input/query to play
|