discord-player 6.6.0-dev → 6.6.0-dev.0
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 -39
- package/dist/index.d.ts +17 -3
- package/dist/index.js +805 -678
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,87 +1,89 @@
|
|
|
1
1
|
# Discord Player
|
|
2
2
|
|
|
3
|
-
Discord Player is a
|
|
4
|
-
It provides easy set of customizable tools to develop Discord Music bots.
|
|
3
|
+
Discord Player is a robust framework for developing Discord Music bots using JavaScript and TypeScript. It is built on top of the [@discordjs/voice](https://npm.im/@discordjs/voice) library and offers a comprehensive set of customizable tools, making it one of the most feature enrich framework in town.
|
|
5
4
|
|
|
6
5
|
[](https://npmjs.com/discord-player)
|
|
7
6
|
[](https://npmjs.com/discord-player)
|
|
8
7
|
[](https://androz2091.fr/discord)
|
|
9
8
|
|
|
10
|
-
# Why Discord Player?
|
|
9
|
+
# Why Choose Discord Player?
|
|
11
10
|
|
|
12
|
-
- Beginner
|
|
11
|
+
- Beginner-friendly with easy-to-understand features
|
|
13
12
|
- TypeScript support
|
|
13
|
+
- Offers hackable APIs.
|
|
14
14
|
- Supports audio player sharing
|
|
15
|
-
- Quick and easy
|
|
15
|
+
- Quick and easy setup process
|
|
16
16
|
- Wide range of player management features
|
|
17
|
-
- 64+ built-in audio filter presets
|
|
18
|
-
- Highly customizable
|
|
17
|
+
- Offers 64+ built-in audio filter presets
|
|
18
|
+
- Highly customizable according to your needs
|
|
19
19
|
- Automatic queue management
|
|
20
20
|
- Query caching support
|
|
21
|
-
-
|
|
22
|
-
- Object
|
|
23
|
-
- Built
|
|
21
|
+
- Extensible sources through the Extractors API
|
|
22
|
+
- Object-oriented design
|
|
23
|
+
- Built-in stats tracker
|
|
24
|
+
- Offers easy debugging methods
|
|
25
|
+
- Out-of-the-box voice states handling
|
|
24
26
|
|
|
25
27
|
## Installation
|
|
26
28
|
|
|
27
29
|
### Before you start
|
|
28
30
|
|
|
29
|
-
Discord Player requires Discord.js 14.0 or higher.
|
|
31
|
+
Discord Player requires Discord.js 14.0 or higher. Please ensure that you have a compatible version by running `npm list discord.js` in your terminal. If you're using an earlier version, please update it. The [discord.js Guide](https://discordjs.guide) provides resources to assist you with the update process.
|
|
30
32
|
|
|
31
33
|
#### Main Library
|
|
32
34
|
|
|
33
35
|
```bash
|
|
34
|
-
$
|
|
35
|
-
$
|
|
36
|
+
$ npm install --save discord-player # main library
|
|
37
|
+
$ npm install --save @discord-player/extractor # extractors provider
|
|
36
38
|
```
|
|
37
39
|
|
|
38
|
-
> Discord Player recognizes `@discord-player/extractor` and loads it automatically by default.
|
|
40
|
+
> Discord Player recognizes `@discord-player/extractor` and loads it automatically by default. Just invoke `await player.extractors.loadDefault()`.
|
|
39
41
|
|
|
40
42
|
#### Opus Library
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
Since Discord only accepts opus packets, you need to install the opus library. Choose one of the following options:
|
|
43
45
|
|
|
44
46
|
```bash
|
|
45
|
-
$
|
|
47
|
+
$ npm install --save @discordjs/opus
|
|
46
48
|
# or
|
|
47
|
-
$
|
|
49
|
+
$ npm install --save opusscript
|
|
48
50
|
```
|
|
49
51
|
|
|
50
52
|
#### FFmpeg or Avconv
|
|
51
53
|
|
|
52
|
-
FFmpeg or Avconv is required for media transcoding. You can
|
|
54
|
+
FFmpeg or Avconv is required for media transcoding. You can obtain it from [https://ffmpeg.org](https://ffmpeg.org) or install it via npm (we recommend against using ffmpeg-static or other binaries):
|
|
53
55
|
|
|
54
56
|
```bash
|
|
55
|
-
$
|
|
57
|
+
$ npm install --save ffmpeg-static
|
|
56
58
|
# or
|
|
57
|
-
$
|
|
59
|
+
$ npm install --save @ffmpeg-installer/ffmpeg
|
|
58
60
|
# or
|
|
59
|
-
$
|
|
61
|
+
$ npm install --save @node-ffmpeg/node-ffmpeg-installer
|
|
60
62
|
# or
|
|
61
|
-
$
|
|
63
|
+
$ npm install --save ffmpeg-binaries
|
|
62
64
|
```
|
|
63
65
|
|
|
64
66
|
> Use `FFMPEG_PATH` environment variable to load ffmpeg from custom path.
|
|
65
67
|
|
|
66
68
|
#### Streaming Library
|
|
67
69
|
|
|
68
|
-
|
|
70
|
+
If you want to add support for YouTube playback, you need to install a streaming library. Choose one of the following options:
|
|
69
71
|
|
|
70
72
|
```bash
|
|
71
|
-
$
|
|
73
|
+
$ npm install --save ytdl-core
|
|
72
74
|
# or
|
|
73
|
-
$
|
|
75
|
+
$ npm install --save play-dl
|
|
74
76
|
# or
|
|
75
|
-
$
|
|
77
|
+
$ npm install --save @distube/ytdl-core
|
|
76
78
|
# or
|
|
77
|
-
$
|
|
79
|
+
$ npm install --save yt-stream
|
|
78
80
|
```
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
Once you have completed these installations, let's proceed with writing a simple music bot.
|
|
81
83
|
|
|
82
84
|
### Setup
|
|
83
85
|
|
|
84
|
-
Let's create a
|
|
86
|
+
Let's create a main player instance. This instance handles and keeps track of all the queues and its components.
|
|
85
87
|
|
|
86
88
|
```js
|
|
87
89
|
const { Player } = require('discord-player');
|
|
@@ -94,7 +96,6 @@ const client = new Discord.Client({
|
|
|
94
96
|
intents: ['GuildVoiceStates' /* Other intents */]
|
|
95
97
|
});
|
|
96
98
|
|
|
97
|
-
|
|
98
99
|
// this is the entrypoint for discord-player based application
|
|
99
100
|
const player = new Player(client);
|
|
100
101
|
|
|
@@ -106,9 +107,7 @@ await player.extractors.register(SpotifyExtractor, {});
|
|
|
106
107
|
await player.extractors.register(SoundCloudExtractor, {});
|
|
107
108
|
```
|
|
108
109
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Now, let's add some event listeners:
|
|
110
|
+
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:
|
|
112
111
|
|
|
113
112
|
```js
|
|
114
113
|
// this event is emitted whenever discord-player starts to play a track
|
|
@@ -118,7 +117,7 @@ player.events.on('playerStart', (queue, track) => {
|
|
|
118
117
|
});
|
|
119
118
|
```
|
|
120
119
|
|
|
121
|
-
Let's
|
|
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 handler part:
|
|
122
121
|
|
|
123
122
|
```js
|
|
124
123
|
async function execute(interaction) {
|
|
@@ -145,11 +144,8 @@ async function execute(interaction) {
|
|
|
145
144
|
}
|
|
146
145
|
```
|
|
147
146
|
|
|
148
|
-
That's all it takes to build your own music bot.
|
|
149
|
-
|
|
150
|
-
#### Check out the [Documentation](https://discord-player.js.org) for more info.
|
|
147
|
+
That's all it takes to build your own music bot. Please check out the [Documentation](https://discord-player.js.org) for more features/functionalities.
|
|
151
148
|
|
|
152
149
|
## Community Resources
|
|
153
150
|
|
|
154
|
-
|
|
155
|
-
[https://discord-player.js.org/docs/guides/community-resources](https://discord-player.js.org/docs/guides/community-resources)
|
|
151
|
+
Explore a curated list of resources built by the Discord Player community, including open-source music bots and extractors. Visit [https://discord-player.js.org/docs/guides/community-resources](https://discord-player.js.org/docs/guides/community-resources) for more information.
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ import { RequestOptions } from 'http';
|
|
|
6
6
|
import * as _discord_player_equalizer from '@discord-player/equalizer';
|
|
7
7
|
import { EqualizerBand, BiquadFilters, PCMFilters, FiltersChain } from '@discord-player/equalizer';
|
|
8
8
|
export { AF_NIGHTCORE_RATE, AF_VAPORWAVE_RATE, BASS_EQ_BANDS, FilterType as BiquadFilterType, BiquadFilters, FiltersChain, AudioFilters as PCMAudioFilters, PCMFilters, Q_BUTTERWORTH, VolumeTransformer } from '@discord-player/equalizer';
|
|
9
|
-
import * as _discordjs_voice from '@discordjs/voice';
|
|
10
9
|
import { StreamType, AudioPlayerError, AudioResource, VoiceConnection, AudioPlayer, AudioPlayerStatus, EndBehaviorType } from '@discordjs/voice';
|
|
11
10
|
export { AudioPlayer, CreateAudioPlayerOptions, createAudioPlayer } from '@discordjs/voice';
|
|
12
11
|
import { downloadOptions } from 'ytdl-core';
|
|
@@ -335,6 +334,7 @@ interface VoiceEvents {
|
|
|
335
334
|
sampleRate: (filters: number) => any;
|
|
336
335
|
biquad: (filters: BiquadFilters) => any;
|
|
337
336
|
volume: (volume: number) => any;
|
|
337
|
+
destroyed: () => any;
|
|
338
338
|
}
|
|
339
339
|
declare class StreamDispatcher extends EventEmitter<VoiceEvents> {
|
|
340
340
|
queue: GuildQueue;
|
|
@@ -414,6 +414,10 @@ declare class StreamDispatcher extends EventEmitter<VoiceEvents> {
|
|
|
414
414
|
* @returns {void}
|
|
415
415
|
*/
|
|
416
416
|
disconnect(): void;
|
|
417
|
+
/**
|
|
418
|
+
* Destroys this dispatcher
|
|
419
|
+
*/
|
|
420
|
+
destroy(): void;
|
|
417
421
|
/**
|
|
418
422
|
* Stops the player
|
|
419
423
|
* @returns {void}
|
|
@@ -1014,6 +1018,7 @@ interface GuildNodeInit<Meta = unknown> {
|
|
|
1014
1018
|
interface VoiceConnectConfig {
|
|
1015
1019
|
deaf?: boolean;
|
|
1016
1020
|
timeout?: number;
|
|
1021
|
+
group?: string;
|
|
1017
1022
|
audioPlayer?: AudioPlayer;
|
|
1018
1023
|
}
|
|
1019
1024
|
interface PostProcessedResult {
|
|
@@ -1367,7 +1372,7 @@ declare class GuildQueue<Meta = unknown> {
|
|
|
1367
1372
|
/**
|
|
1368
1373
|
* The voice connection of this queue
|
|
1369
1374
|
*/
|
|
1370
|
-
get connection():
|
|
1375
|
+
get connection(): VoiceConnection | null;
|
|
1371
1376
|
/**
|
|
1372
1377
|
* The guild this queue belongs to
|
|
1373
1378
|
*/
|
|
@@ -1478,6 +1483,11 @@ declare class GuildQueue<Meta = unknown> {
|
|
|
1478
1483
|
* @param dest The second track to swap
|
|
1479
1484
|
*/
|
|
1480
1485
|
swapTracks(src: TrackResolvable, dest: TrackResolvable): void;
|
|
1486
|
+
/**
|
|
1487
|
+
* Create stream dispatcher from the given connection
|
|
1488
|
+
* @param connection The connection to use
|
|
1489
|
+
*/
|
|
1490
|
+
createDispatcher(connection: VoiceConnection, options?: Pick<VoiceConnectConfig, 'audioPlayer' | 'timeout'>): void;
|
|
1481
1491
|
/**
|
|
1482
1492
|
* Connect to a voice channel
|
|
1483
1493
|
* @param channelResolvable The voice channel to connect to
|
|
@@ -1521,6 +1531,7 @@ declare class GuildQueue<Meta = unknown> {
|
|
|
1521
1531
|
* @param args The args for the event
|
|
1522
1532
|
*/
|
|
1523
1533
|
emit<K extends keyof GuildQueueEvents<Meta>>(event: K, ...args: Parameters<GuildQueueEvents<Meta>[K]>): boolean;
|
|
1534
|
+
get hasDebugger(): boolean;
|
|
1524
1535
|
}
|
|
1525
1536
|
|
|
1526
1537
|
interface GuildQueueStatisticsMetadata {
|
|
@@ -1643,6 +1654,7 @@ declare class VoiceUtils {
|
|
|
1643
1654
|
maxTime?: number;
|
|
1644
1655
|
queue: GuildQueue;
|
|
1645
1656
|
audioPlayer?: AudioPlayer;
|
|
1657
|
+
group?: string;
|
|
1646
1658
|
}): Promise<StreamDispatcher>;
|
|
1647
1659
|
/**
|
|
1648
1660
|
* Joins a voice channel
|
|
@@ -1653,6 +1665,7 @@ declare class VoiceUtils {
|
|
|
1653
1665
|
join(channel: VoiceChannel | StageChannel, options?: {
|
|
1654
1666
|
deaf?: boolean;
|
|
1655
1667
|
maxTime?: number;
|
|
1668
|
+
group?: string;
|
|
1656
1669
|
}): Promise<VoiceConnection>;
|
|
1657
1670
|
/**
|
|
1658
1671
|
* Disconnects voice connection
|
|
@@ -1665,7 +1678,7 @@ declare class VoiceUtils {
|
|
|
1665
1678
|
* @param {Snowflake} guild The guild id
|
|
1666
1679
|
* @returns {StreamDispatcher}
|
|
1667
1680
|
*/
|
|
1668
|
-
getConnection(guild: Snowflake): StreamDispatcher | VoiceConnection | undefined;
|
|
1681
|
+
getConnection(guild: Snowflake, group?: string): StreamDispatcher | VoiceConnection | undefined;
|
|
1669
1682
|
}
|
|
1670
1683
|
|
|
1671
1684
|
interface QueryCacheOptions {
|
|
@@ -1727,6 +1740,7 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
|
1727
1740
|
* @param {PlayerInitOptions} [options] The player init options
|
|
1728
1741
|
*/
|
|
1729
1742
|
constructor(client: Client, options?: PlayerInitOptions);
|
|
1743
|
+
get hasDebugger(): boolean;
|
|
1730
1744
|
/**
|
|
1731
1745
|
* Override default voice state update handler
|
|
1732
1746
|
* @param handler The handler callback
|