discord-player 5.2.1 → 6.0.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/LICENSE +21 -21
- package/README.md +3 -1
- package/dist/Player.js +279 -272
- package/dist/Structures/ExtractorModel.js +19 -24
- package/dist/Structures/Playlist.js +1 -2
- package/dist/Structures/Queue.js +259 -269
- package/dist/Structures/Track.js +11 -14
- package/dist/VoiceInterface/StreamDispatcher.js +34 -38
- package/dist/VoiceInterface/VoiceUtils.js +22 -25
- package/dist/{VolumeTransformer.js → VoiceInterface/VolumeTransformer.js} +35 -9
- package/dist/index.d.ts +12 -7
- package/dist/index.js +3 -1
- package/dist/smoothVolume.js +11 -3
- package/dist/utils/Util.js +34 -1
- package/package.json +28 -31
package/dist/Structures/Track.js
CHANGED
|
@@ -10,7 +10,7 @@ class Track {
|
|
|
10
10
|
*/
|
|
11
11
|
constructor(player, data) {
|
|
12
12
|
this.raw = {};
|
|
13
|
-
this.id = discord_js_1.SnowflakeUtil.generate();
|
|
13
|
+
this.id = discord_js_1.SnowflakeUtil.generate().toString();
|
|
14
14
|
/**
|
|
15
15
|
* The player that instantiated this Track
|
|
16
16
|
* @name Track#player
|
|
@@ -82,17 +82,16 @@ class Track {
|
|
|
82
82
|
void this._patch(data);
|
|
83
83
|
}
|
|
84
84
|
_patch(data) {
|
|
85
|
-
|
|
86
|
-
this.
|
|
87
|
-
this.
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
90
|
-
this.
|
|
91
|
-
this.views = (_f = data.views) !== null && _f !== void 0 ? _f : 0;
|
|
85
|
+
this.title = (0, discord_js_1.escapeMarkdown)(data.title ?? "");
|
|
86
|
+
this.author = data.author ?? "";
|
|
87
|
+
this.url = data.url ?? "";
|
|
88
|
+
this.thumbnail = data.thumbnail ?? "";
|
|
89
|
+
this.duration = data.duration ?? "";
|
|
90
|
+
this.views = data.views ?? 0;
|
|
92
91
|
this.requestedBy = data.requestedBy;
|
|
93
92
|
this.playlist = data.playlist;
|
|
94
93
|
// raw
|
|
95
|
-
Object.defineProperty(this, "raw", { value: Object.assign({}, { source:
|
|
94
|
+
Object.defineProperty(this, "raw", { value: Object.assign({}, { source: data.raw?.source ?? data.source }, data.raw ?? data), enumerable: false });
|
|
96
95
|
}
|
|
97
96
|
/**
|
|
98
97
|
* The queue in which this track is located
|
|
@@ -123,8 +122,7 @@ class Track {
|
|
|
123
122
|
* @type {TrackSource}
|
|
124
123
|
*/
|
|
125
124
|
get source() {
|
|
126
|
-
|
|
127
|
-
return (_a = this.raw.source) !== null && _a !== void 0 ? _a : "arbitrary";
|
|
125
|
+
return this.raw.source ?? "arbitrary";
|
|
128
126
|
}
|
|
129
127
|
/**
|
|
130
128
|
* String representation of this track
|
|
@@ -138,7 +136,6 @@ class Track {
|
|
|
138
136
|
* @returns {TrackJSON}
|
|
139
137
|
*/
|
|
140
138
|
toJSON(hidePlaylist) {
|
|
141
|
-
var _a, _b, _c;
|
|
142
139
|
return {
|
|
143
140
|
id: this.id,
|
|
144
141
|
title: this.title,
|
|
@@ -149,8 +146,8 @@ class Track {
|
|
|
149
146
|
duration: this.duration,
|
|
150
147
|
durationMS: this.durationMS,
|
|
151
148
|
views: this.views,
|
|
152
|
-
requestedBy:
|
|
153
|
-
playlist: hidePlaylist ? null :
|
|
149
|
+
requestedBy: this.requestedBy?.id,
|
|
150
|
+
playlist: hidePlaylist ? null : this.playlist?.toJSON() ?? null
|
|
154
151
|
};
|
|
155
152
|
}
|
|
156
153
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StreamDispatcher = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const voice_1 = require("@discordjs/voice");
|
|
6
5
|
const tiny_typed_emitter_1 = require("tiny-typed-emitter");
|
|
7
6
|
const Util_1 = require("../utils/Util");
|
|
@@ -37,13 +36,14 @@ class StreamDispatcher extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
37
36
|
* @type {boolean}
|
|
38
37
|
*/
|
|
39
38
|
this.paused = false;
|
|
40
|
-
|
|
39
|
+
// @ts-expect-error ???
|
|
40
|
+
this.voiceConnection.on("stateChange", async (_, newState) => {
|
|
41
41
|
if (newState.status === voice_1.VoiceConnectionStatus.Disconnected) {
|
|
42
42
|
if (newState.reason === voice_1.VoiceConnectionDisconnectReason.WebSocketClose && newState.closeCode === 4014) {
|
|
43
43
|
try {
|
|
44
|
-
|
|
44
|
+
await (0, voice_1.entersState)(this.voiceConnection, voice_1.VoiceConnectionStatus.Connecting, this.connectionTimeout);
|
|
45
45
|
}
|
|
46
|
-
catch
|
|
46
|
+
catch {
|
|
47
47
|
try {
|
|
48
48
|
this.voiceConnection.destroy();
|
|
49
49
|
}
|
|
@@ -53,7 +53,7 @@ class StreamDispatcher extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
else if (this.voiceConnection.rejoinAttempts < 5) {
|
|
56
|
-
|
|
56
|
+
await Util_1.Util.wait((this.voiceConnection.rejoinAttempts + 1) * 5000);
|
|
57
57
|
this.voiceConnection.rejoin();
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
@@ -71,9 +71,9 @@ class StreamDispatcher extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
71
71
|
else if (!this.readyLock && (newState.status === voice_1.VoiceConnectionStatus.Connecting || newState.status === voice_1.VoiceConnectionStatus.Signalling)) {
|
|
72
72
|
this.readyLock = true;
|
|
73
73
|
try {
|
|
74
|
-
|
|
74
|
+
await (0, voice_1.entersState)(this.voiceConnection, voice_1.VoiceConnectionStatus.Ready, this.connectionTimeout);
|
|
75
75
|
}
|
|
76
|
-
catch
|
|
76
|
+
catch {
|
|
77
77
|
if (this.voiceConnection.state.status !== voice_1.VoiceConnectionStatus.Destroyed) {
|
|
78
78
|
try {
|
|
79
79
|
this.voiceConnection.destroy();
|
|
@@ -87,7 +87,8 @@ class StreamDispatcher extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
87
87
|
this.readyLock = false;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
})
|
|
90
|
+
});
|
|
91
|
+
// @ts-expect-error ???
|
|
91
92
|
this.audioPlayer.on("stateChange", (oldState, newState) => {
|
|
92
93
|
if (newState.status === voice_1.AudioPlayerStatus.Playing) {
|
|
93
94
|
if (!this.paused)
|
|
@@ -112,12 +113,11 @@ class StreamDispatcher extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
112
113
|
*/
|
|
113
114
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
115
|
createStream(src, ops) {
|
|
115
|
-
var _a;
|
|
116
116
|
this.audioResource = (0, voice_1.createAudioResource)(src, {
|
|
117
|
-
inputType:
|
|
118
|
-
metadata: ops
|
|
117
|
+
inputType: ops?.type ?? voice_1.StreamType.Arbitrary,
|
|
118
|
+
metadata: ops?.data,
|
|
119
119
|
// eslint-disable-next-line no-extra-boolean-cast
|
|
120
|
-
inlineVolume: !Boolean(ops
|
|
120
|
+
inlineVolume: !Boolean(ops?.disableVolume)
|
|
121
121
|
});
|
|
122
122
|
return this.audioResource;
|
|
123
123
|
}
|
|
@@ -137,7 +137,7 @@ class StreamDispatcher extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
137
137
|
this.audioPlayer.stop(true);
|
|
138
138
|
this.voiceConnection.destroy();
|
|
139
139
|
}
|
|
140
|
-
catch
|
|
140
|
+
catch { } // eslint-disable-line no-empty
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
143
|
* Stops the player
|
|
@@ -170,30 +170,28 @@ class StreamDispatcher extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
170
170
|
* @param {AudioResource<Track>} [resource=this.audioResource] The audio resource to play
|
|
171
171
|
* @returns {Promise<StreamDispatcher>}
|
|
172
172
|
*/
|
|
173
|
-
playStream(resource = this.audioResource) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (this.voiceConnection.state.status !== voice_1.VoiceConnectionStatus.Ready) {
|
|
182
|
-
try {
|
|
183
|
-
yield (0, voice_1.entersState)(this.voiceConnection, voice_1.VoiceConnectionStatus.Ready, this.connectionTimeout);
|
|
184
|
-
}
|
|
185
|
-
catch (err) {
|
|
186
|
-
return void this.emit("error", err);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
173
|
+
async playStream(resource = this.audioResource) {
|
|
174
|
+
if (!resource)
|
|
175
|
+
throw new PlayerError_1.PlayerError("Audio resource is not available!", PlayerError_1.ErrorStatusCode.NO_AUDIO_RESOURCE);
|
|
176
|
+
if (resource.ended)
|
|
177
|
+
return void this.emit("error", new PlayerError_1.PlayerError("Cannot play a resource that has already ended."));
|
|
178
|
+
if (!this.audioResource)
|
|
179
|
+
this.audioResource = resource;
|
|
180
|
+
if (this.voiceConnection.state.status !== voice_1.VoiceConnectionStatus.Ready) {
|
|
189
181
|
try {
|
|
190
|
-
this.
|
|
182
|
+
await (0, voice_1.entersState)(this.voiceConnection, voice_1.VoiceConnectionStatus.Ready, this.connectionTimeout);
|
|
191
183
|
}
|
|
192
|
-
catch (
|
|
193
|
-
this.emit("error",
|
|
184
|
+
catch (err) {
|
|
185
|
+
return void this.emit("error", err);
|
|
194
186
|
}
|
|
195
|
-
|
|
196
|
-
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
this.audioPlayer.play(resource);
|
|
190
|
+
}
|
|
191
|
+
catch (e) {
|
|
192
|
+
this.emit("error", e);
|
|
193
|
+
}
|
|
194
|
+
return this;
|
|
197
195
|
}
|
|
198
196
|
/**
|
|
199
197
|
* Sets playback volume
|
|
@@ -201,8 +199,7 @@ class StreamDispatcher extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
201
199
|
* @returns {boolean}
|
|
202
200
|
*/
|
|
203
201
|
setVolume(value) {
|
|
204
|
-
|
|
205
|
-
if (!((_a = this.audioResource) === null || _a === void 0 ? void 0 : _a.volume) || isNaN(value) || value < 0 || value > Infinity)
|
|
202
|
+
if (!this.audioResource?.volume || isNaN(value) || value < 0 || value > Infinity)
|
|
206
203
|
return false;
|
|
207
204
|
this.audioResource.volume.setVolumeLogarithmic(value / 100);
|
|
208
205
|
return true;
|
|
@@ -212,8 +209,7 @@ class StreamDispatcher extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
212
209
|
* @type {number}
|
|
213
210
|
*/
|
|
214
211
|
get volume() {
|
|
215
|
-
|
|
216
|
-
if (!((_a = this.audioResource) === null || _a === void 0 ? void 0 : _a.volume))
|
|
212
|
+
if (!this.audioResource?.volume)
|
|
217
213
|
return 100;
|
|
218
214
|
const currentVol = this.audioResource.volume.volume;
|
|
219
215
|
return Math.round(Math.pow(currentVol, 1 / 1.660964) * 100);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VoiceUtils = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const discord_js_1 = require("discord.js");
|
|
6
5
|
const voice_1 = require("@discordjs/voice");
|
|
7
6
|
const StreamDispatcher_1 = require("./StreamDispatcher");
|
|
@@ -23,13 +22,11 @@ class VoiceUtils {
|
|
|
23
22
|
* @param {object} [options={}] Join options
|
|
24
23
|
* @returns {Promise<StreamDispatcher>}
|
|
25
24
|
*/
|
|
26
|
-
connect(channel, options) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return sub;
|
|
32
|
-
});
|
|
25
|
+
async connect(channel, options) {
|
|
26
|
+
const conn = await this.join(channel, options);
|
|
27
|
+
const sub = new StreamDispatcher_1.StreamDispatcher(conn, channel, options.maxTime);
|
|
28
|
+
this.cache.set(channel.guild.id, sub);
|
|
29
|
+
return sub;
|
|
33
30
|
}
|
|
34
31
|
/**
|
|
35
32
|
* Joins a voice channel
|
|
@@ -37,24 +34,24 @@ class VoiceUtils {
|
|
|
37
34
|
* @param {object} [options={}] Join options
|
|
38
35
|
* @returns {VoiceConnection}
|
|
39
36
|
*/
|
|
40
|
-
join(channel, options) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
adapterCreator: channel.guild.voiceAdapterCreator,
|
|
47
|
-
selfDeaf: Boolean(options.deaf)
|
|
48
|
-
});
|
|
49
|
-
try {
|
|
50
|
-
conn = yield (0, voice_1.entersState)(conn, voice_1.VoiceConnectionStatus.Ready, (_a = options === null || options === void 0 ? void 0 : options.maxTime) !== null && _a !== void 0 ? _a : 20000);
|
|
51
|
-
return conn;
|
|
52
|
-
}
|
|
53
|
-
catch (err) {
|
|
54
|
-
conn.destroy();
|
|
55
|
-
throw err;
|
|
56
|
-
}
|
|
37
|
+
async join(channel, options) {
|
|
38
|
+
const conn = (0, voice_1.joinVoiceChannel)({
|
|
39
|
+
guildId: channel.guild.id,
|
|
40
|
+
channelId: channel.id,
|
|
41
|
+
adapterCreator: channel.guild.voiceAdapterCreator,
|
|
42
|
+
selfDeaf: Boolean(options.deaf)
|
|
57
43
|
});
|
|
44
|
+
return conn;
|
|
45
|
+
}
|
|
46
|
+
async enterReady(conn, options = {}) {
|
|
47
|
+
try {
|
|
48
|
+
conn = await (0, voice_1.entersState)(conn, voice_1.VoiceConnectionStatus.Ready, options?.maxTime ?? 20000);
|
|
49
|
+
return conn;
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
conn.destroy();
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
58
55
|
}
|
|
59
56
|
/**
|
|
60
57
|
* Disconnects voice connection
|
|
@@ -30,9 +30,12 @@ class VolumeTransformer extends stream_1.Transform {
|
|
|
30
30
|
default:
|
|
31
31
|
throw new Error("VolumeTransformer type should be one of s16le, s16be, s32le, s32be");
|
|
32
32
|
}
|
|
33
|
+
this.type = options.type;
|
|
33
34
|
this._bytes = this._bits / 8;
|
|
34
35
|
this._extremum = Math.pow(2, this._bits - 1);
|
|
35
|
-
this.volume =
|
|
36
|
+
this.volume = Number.isNaN(options.volume) ? 1 : Number(options.volume);
|
|
37
|
+
if (!Number.isFinite(this.volume))
|
|
38
|
+
this.volume = 1;
|
|
36
39
|
this._targetVolume = this.volume;
|
|
37
40
|
this._chunk = Buffer.alloc(0);
|
|
38
41
|
this._smoothing = options.smoothness || 0;
|
|
@@ -43,15 +46,17 @@ class VolumeTransformer extends stream_1.Transform {
|
|
|
43
46
|
_writeInt(buffer, int, index) {
|
|
44
47
|
return index;
|
|
45
48
|
}
|
|
46
|
-
|
|
47
|
-
if (this.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this.volume = this.volume - this._smoothing <= this._targetVolume ? this._targetVolume : this.volume - this._smoothing;
|
|
53
|
-
}
|
|
49
|
+
_applySmoothness() {
|
|
50
|
+
if (this.volume < this._targetVolume) {
|
|
51
|
+
this.volume = this.volume + this._smoothing >= this._targetVolume ? this._targetVolume : this.volume + this._smoothing;
|
|
52
|
+
}
|
|
53
|
+
else if (this.volume > this._targetVolume) {
|
|
54
|
+
this.volume = this.volume - this._smoothing <= this._targetVolume ? this._targetVolume : this.volume - this._smoothing;
|
|
54
55
|
}
|
|
56
|
+
}
|
|
57
|
+
_transform(chunk, encoding, done) {
|
|
58
|
+
if (this.smoothingEnabled() && this.volume !== this._targetVolume)
|
|
59
|
+
this._applySmoothness();
|
|
55
60
|
if (this.volume === 1) {
|
|
56
61
|
this.push(chunk);
|
|
57
62
|
return done();
|
|
@@ -74,6 +79,12 @@ class VolumeTransformer extends stream_1.Transform {
|
|
|
74
79
|
this._chunk = null;
|
|
75
80
|
}
|
|
76
81
|
setVolume(volume) {
|
|
82
|
+
if (Number.isNaN(volume))
|
|
83
|
+
volume = 1;
|
|
84
|
+
if (typeof volume !== "number")
|
|
85
|
+
volume = Number(volume);
|
|
86
|
+
if (!Number.isFinite(volume))
|
|
87
|
+
volume = volume < 0 ? 0 : 1;
|
|
77
88
|
this._targetVolume = volume;
|
|
78
89
|
if (this._smoothing <= 0)
|
|
79
90
|
this.volume = volume;
|
|
@@ -90,5 +101,20 @@ class VolumeTransformer extends stream_1.Transform {
|
|
|
90
101
|
get volumeLogarithmic() {
|
|
91
102
|
return Math.pow(this.volume, 1 / 1.660964);
|
|
92
103
|
}
|
|
104
|
+
get smoothness() {
|
|
105
|
+
return this._smoothing;
|
|
106
|
+
}
|
|
107
|
+
setSmoothness(smoothness) {
|
|
108
|
+
this._smoothing = smoothness;
|
|
109
|
+
}
|
|
110
|
+
smoothingEnabled() {
|
|
111
|
+
return Number.isFinite(this._smoothing) && this._smoothing > 0;
|
|
112
|
+
}
|
|
113
|
+
get hasSmoothness() {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
static get hasSmoothing() {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
93
119
|
}
|
|
94
120
|
exports.VolumeTransformer = VolumeTransformer;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { User,
|
|
2
|
+
import { User, VoiceChannel, StageChannel, Collection, Snowflake, Client, GuildResolvable, Guild, GuildChannelResolvable, UserResolvable } from 'discord.js';
|
|
3
3
|
import { Readable, Duplex } from 'stream';
|
|
4
4
|
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
5
5
|
import { AudioPlayerError, AudioResource, VoiceConnection, AudioPlayer, StreamType, AudioPlayerStatus } from '@discordjs/voice';
|
|
6
6
|
import { downloadOptions } from 'ytdl-core';
|
|
7
|
+
import * as undici from 'undici';
|
|
7
8
|
|
|
8
9
|
declare class Playlist {
|
|
9
10
|
readonly player: Player;
|
|
@@ -47,7 +48,7 @@ declare class Track {
|
|
|
47
48
|
requestedBy: User;
|
|
48
49
|
playlist?: Playlist;
|
|
49
50
|
readonly raw: RawTrackData;
|
|
50
|
-
readonly id:
|
|
51
|
+
readonly id: string;
|
|
51
52
|
/**
|
|
52
53
|
* Track constructor
|
|
53
54
|
* @param {Player} player The player that instantiated this Track
|
|
@@ -191,6 +192,9 @@ declare class VoiceUtils {
|
|
|
191
192
|
deaf?: boolean;
|
|
192
193
|
maxTime?: number;
|
|
193
194
|
}): Promise<VoiceConnection>;
|
|
195
|
+
enterReady(conn: VoiceConnection, options?: {
|
|
196
|
+
maxTime?: number;
|
|
197
|
+
}): Promise<VoiceConnection>;
|
|
194
198
|
/**
|
|
195
199
|
* Disconnects voice connection
|
|
196
200
|
* @param {VoiceConnection} connection The voice connection
|
|
@@ -327,7 +331,7 @@ declare class Queue<T = unknown> {
|
|
|
327
331
|
playing: boolean;
|
|
328
332
|
metadata?: T;
|
|
329
333
|
repeatMode: QueueRepeatMode;
|
|
330
|
-
readonly id:
|
|
334
|
+
readonly id: string;
|
|
331
335
|
private _streamTime;
|
|
332
336
|
_cooldownsTimeout: Collection<string, NodeJS.Timeout>;
|
|
333
337
|
private _activeFilters;
|
|
@@ -462,16 +466,16 @@ declare class Queue<T = unknown> {
|
|
|
462
466
|
shuffle(): boolean;
|
|
463
467
|
/**
|
|
464
468
|
* Removes a track from the queue
|
|
465
|
-
* @param {Track|
|
|
469
|
+
* @param {Track|string|number} track The track to remove
|
|
466
470
|
* @returns {Track}
|
|
467
471
|
*/
|
|
468
|
-
remove(track: Track |
|
|
472
|
+
remove(track: Track | string | number): Track;
|
|
469
473
|
/**
|
|
470
474
|
* Returns the index of the specified track. If found, returns the track index else returns -1.
|
|
471
|
-
* @param {number|Track|
|
|
475
|
+
* @param {number|Track|string} track The track
|
|
472
476
|
* @returns {number}
|
|
473
477
|
*/
|
|
474
|
-
getTrackPosition(track: number | Track |
|
|
478
|
+
getTrackPosition(track: number | Track | string): number;
|
|
475
479
|
/**
|
|
476
480
|
* Jumps to particular track
|
|
477
481
|
* @param {Track|number} track The track
|
|
@@ -1181,6 +1185,7 @@ declare class Util {
|
|
|
1181
1185
|
*/
|
|
1182
1186
|
static wait(time: number): Promise<unknown>;
|
|
1183
1187
|
static noop(): void;
|
|
1188
|
+
static getFetch(): Promise<typeof fetch | typeof undici.default>;
|
|
1184
1189
|
}
|
|
1185
1190
|
|
|
1186
1191
|
declare const version: string;
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.version = exports.Util = exports.StreamDispatcher = exports.VoiceUtils = exports.Track = exports.Queue = exports.QueryResolver = exports.ErrorStatusCode = exports.PlayerError = exports.Player = exports.Playlist = exports.ExtractorModel = exports.AudioFilters = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
// try applying smooth volume patch on load
|
|
6
|
+
require("./smoothVolume");
|
|
5
7
|
var AudioFilters_1 = require("./utils/AudioFilters");
|
|
6
8
|
Object.defineProperty(exports, "AudioFilters", { enumerable: true, get: function () { return AudioFilters_1.AudioFilters; } });
|
|
7
9
|
var ExtractorModel_1 = require("./Structures/ExtractorModel");
|
|
@@ -25,6 +27,6 @@ var StreamDispatcher_1 = require("./VoiceInterface/StreamDispatcher");
|
|
|
25
27
|
Object.defineProperty(exports, "StreamDispatcher", { enumerable: true, get: function () { return StreamDispatcher_1.StreamDispatcher; } });
|
|
26
28
|
var Util_1 = require("./utils/Util");
|
|
27
29
|
Object.defineProperty(exports, "Util", { enumerable: true, get: function () { return Util_1.Util; } });
|
|
28
|
-
|
|
30
|
+
tslib_1.__exportStar(require("./types/types"), exports);
|
|
29
31
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
30
32
|
exports.version = require(`${__dirname}/../package.json`).version;
|
package/dist/smoothVolume.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const VolumeTransformer_1 = require("./VolumeTransformer");
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const VolumeTransformer_1 = require("./VoiceInterface/VolumeTransformer");
|
|
4
|
+
try {
|
|
5
|
+
// eslint-disable-next-line
|
|
6
|
+
const mod = require("prism-media");
|
|
7
|
+
if (typeof mod.VolumeTransformer.hasSmoothing !== "boolean") {
|
|
8
|
+
Reflect.set(mod, "VolumeTransformer", VolumeTransformer_1.VolumeTransformer);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
/* do nothing */
|
|
13
|
+
}
|
package/dist/utils/Util.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.Util = void 0;
|
|
4
27
|
class Util {
|
|
@@ -73,7 +96,7 @@ class Util {
|
|
|
73
96
|
try {
|
|
74
97
|
return require(id);
|
|
75
98
|
}
|
|
76
|
-
catch
|
|
99
|
+
catch {
|
|
77
100
|
return null;
|
|
78
101
|
}
|
|
79
102
|
}
|
|
@@ -86,5 +109,15 @@ class Util {
|
|
|
86
109
|
return new Promise((r) => setTimeout(r, time).unref());
|
|
87
110
|
}
|
|
88
111
|
static noop() { } // eslint-disable-line @typescript-eslint/no-empty-function
|
|
112
|
+
static async getFetch() {
|
|
113
|
+
if ("fetch" in globalThis)
|
|
114
|
+
return globalThis.fetch;
|
|
115
|
+
try {
|
|
116
|
+
return await Promise.resolve().then(() => __importStar(require("undici"))).then((res) => res.default);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// uh?
|
|
120
|
+
}
|
|
121
|
+
}
|
|
89
122
|
}
|
|
90
123
|
exports.Util = Util;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discord-player",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-dev.0",
|
|
4
4
|
"description": "Complete framework to facilitate music commands using discord.js",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
"require": "./dist/index.js",
|
|
14
14
|
"import": "./dist/index.mjs"
|
|
15
15
|
},
|
|
16
|
-
"./smoothVolume": "./dist/smoothVolume.js"
|
|
16
|
+
"./smoothVolume": "./dist/smoothVolume.js",
|
|
17
|
+
"./src/*": "./dist/*",
|
|
18
|
+
"./dist/*": "./dist/*"
|
|
17
19
|
},
|
|
18
20
|
"scripts": {
|
|
19
21
|
"dev": "cd example/test && ts-node index.ts",
|
|
@@ -21,9 +23,9 @@
|
|
|
21
23
|
"build:check": "tsc --noEmit --incremental false",
|
|
22
24
|
"prepublishOnly": "rollup-type-bundler -e stream",
|
|
23
25
|
"build:esm": "gen-esm-wrapper ./dist/index.js ./dist/index.mjs",
|
|
24
|
-
"format": "prettier --write \"src/**/*.ts\"
|
|
25
|
-
"docs": "
|
|
26
|
-
"
|
|
26
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
27
|
+
"docs": "typedoc --json docs/typedoc.json src/index.ts",
|
|
28
|
+
"postdocs": "node scripts/docgen.js",
|
|
27
29
|
"lint": "eslint src --ext .ts",
|
|
28
30
|
"prepare": "husky install",
|
|
29
31
|
"lint:fix": "eslint src --ext .ts --fix"
|
|
@@ -63,37 +65,32 @@
|
|
|
63
65
|
},
|
|
64
66
|
"homepage": "https://discord-player.js.org",
|
|
65
67
|
"dependencies": {
|
|
66
|
-
"@discordjs/voice": "^0.
|
|
68
|
+
"@discordjs/voice": "^0.10.0",
|
|
67
69
|
"discord-ytdl-core": "^5.0.4",
|
|
68
|
-
"libsodium-wrappers": "^0.7.
|
|
70
|
+
"libsodium-wrappers": "^0.7.10",
|
|
69
71
|
"soundcloud-scraper": "^5.0.2",
|
|
70
|
-
"spotify-url-info": "^
|
|
71
|
-
"
|
|
72
|
-
"youtube-sr": "^4.1.
|
|
73
|
-
"ytdl-core": "^4.
|
|
72
|
+
"spotify-url-info": "^3.1.2",
|
|
73
|
+
"tslib": "^2.4.0",
|
|
74
|
+
"youtube-sr": "^4.1.17",
|
|
75
|
+
"ytdl-core": "^4.11.0"
|
|
74
76
|
},
|
|
75
77
|
"devDependencies": {
|
|
76
|
-
"@
|
|
77
|
-
"@
|
|
78
|
-
"@
|
|
79
|
-
"@
|
|
80
|
-
"@
|
|
81
|
-
"@
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"@types/ws": "^8.2.0",
|
|
86
|
-
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
|
87
|
-
"@typescript-eslint/parser": "^5.4.0",
|
|
88
|
-
"discord-api-types": "^0.24.0",
|
|
89
|
-
"discord.js": "^13.3.1",
|
|
90
|
-
"eslint": "^8.3.0",
|
|
78
|
+
"@discordjs/ts-docgen": "^0.4.1",
|
|
79
|
+
"@favware/rollup-type-bundler": "^1.0.7",
|
|
80
|
+
"@types/node": "^17.0.43",
|
|
81
|
+
"@types/ws": "^8.5.3",
|
|
82
|
+
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
|
83
|
+
"@typescript-eslint/parser": "^5.28.0",
|
|
84
|
+
"discord-api-types": "^0.34.0",
|
|
85
|
+
"discord.js": "^14.0.0-dev.1655165434-b4e28a8",
|
|
86
|
+
"eslint": "^8.17.0",
|
|
91
87
|
"gen-esm-wrapper": "^1.1.3",
|
|
92
|
-
"husky": "^
|
|
93
|
-
"
|
|
94
|
-
"prettier": "^2.
|
|
88
|
+
"husky": "^8.0.1",
|
|
89
|
+
"opusscript": "^0.0.8",
|
|
90
|
+
"prettier": "^2.7.0",
|
|
95
91
|
"rimraf": "^3.0.2",
|
|
96
|
-
"ts-node": "^10.
|
|
97
|
-
"
|
|
92
|
+
"ts-node": "^10.8.1",
|
|
93
|
+
"typedoc": "^0.22.17",
|
|
94
|
+
"typescript": "^4.7.3"
|
|
98
95
|
}
|
|
99
96
|
}
|