discord-player 6.0.0-dev.0 → 6.0.0-dev.1
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 +1 -1
- package/README.md +170 -119
- package/dist/index.d.ts +837 -207
- package/dist/index.js +2950 -32
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2911 -18
- package/dist/index.mjs.map +1 -0
- package/package.json +25 -36
- package/dist/Player.js +0 -563
- package/dist/Structures/ExtractorModel.js +0 -65
- package/dist/Structures/PlayerError.js +0 -48
- package/dist/Structures/Playlist.js +0 -108
- package/dist/Structures/Queue.js +0 -788
- package/dist/Structures/Track.js +0 -155
- package/dist/VoiceInterface/StreamDispatcher.js +0 -227
- package/dist/VoiceInterface/VoiceUtils.js +0 -75
- package/dist/VoiceInterface/VolumeTransformer.js +0 -120
- package/dist/smoothVolume.js +0 -13
- package/dist/types/types.js +0 -58
- package/dist/utils/AudioFilters.js +0 -109
- package/dist/utils/QueryResolver.js +0 -68
- package/dist/utils/Util.js +0 -123
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AudioFilters = void 0;
|
|
4
|
-
const bass = (g) => `bass=g=${g}:f=110:w=0.3`;
|
|
5
|
-
/**
|
|
6
|
-
* The available audio filters
|
|
7
|
-
* @typedef {object} AudioFilters
|
|
8
|
-
* @property {string} bassboost_low The bassboost filter (+15dB)
|
|
9
|
-
* @property {string} bassboost The bassboost filter (+20dB)
|
|
10
|
-
* @property {string} bassboost_high The bassboost filter (+30dB)
|
|
11
|
-
* @property {string} 8D The 8D filter
|
|
12
|
-
* @property {string} vaporwave The vaporwave filter
|
|
13
|
-
* @property {string} nightcore The nightcore filter
|
|
14
|
-
* @property {string} phaser The phaser filter
|
|
15
|
-
* @property {string} tremolo The tremolo filter
|
|
16
|
-
* @property {string} vibrato The vibrato filter
|
|
17
|
-
* @property {string} reverse The reverse filter
|
|
18
|
-
* @property {string} treble The treble filter
|
|
19
|
-
* @property {string} normalizer The normalizer filter (dynamic audio normalizer based)
|
|
20
|
-
* @property {string} normalizer2 The normalizer filter (audio compressor based)
|
|
21
|
-
* @property {string} surrounding The surrounding filter
|
|
22
|
-
* @property {string} pulsator The pulsator filter
|
|
23
|
-
* @property {string} subboost The subboost filter
|
|
24
|
-
* @property {string} karaoke The kakaoke filter
|
|
25
|
-
* @property {string} flanger The flanger filter
|
|
26
|
-
* @property {string} gate The gate filter
|
|
27
|
-
* @property {string} haas The haas filter
|
|
28
|
-
* @property {string} mcompand The mcompand filter
|
|
29
|
-
* @property {string} mono The mono filter
|
|
30
|
-
* @property {string} mstlr The mstlr filter
|
|
31
|
-
* @property {string} mstrr The mstrr filter
|
|
32
|
-
* @property {string} compressor The compressor filter
|
|
33
|
-
* @property {string} expander The expander filter
|
|
34
|
-
* @property {string} softlimiter The softlimiter filter
|
|
35
|
-
* @property {string} chorus The chorus filter
|
|
36
|
-
* @property {string} chorus2d The chorus2d filter
|
|
37
|
-
* @property {string} chorus3d The chorus3d filter
|
|
38
|
-
* @property {string} fadein The fadein filter
|
|
39
|
-
* @property {string} dim The dim filter
|
|
40
|
-
* @property {string} earrape The earrape filter
|
|
41
|
-
*/
|
|
42
|
-
const FilterList = {
|
|
43
|
-
bassboost_low: bass(15),
|
|
44
|
-
bassboost: bass(20),
|
|
45
|
-
bassboost_high: bass(30),
|
|
46
|
-
"8D": "apulsator=hz=0.09",
|
|
47
|
-
vaporwave: "aresample=48000,asetrate=48000*0.8",
|
|
48
|
-
nightcore: "aresample=48000,asetrate=48000*1.25",
|
|
49
|
-
phaser: "aphaser=in_gain=0.4",
|
|
50
|
-
tremolo: "tremolo",
|
|
51
|
-
vibrato: "vibrato=f=6.5",
|
|
52
|
-
reverse: "areverse",
|
|
53
|
-
treble: "treble=g=5",
|
|
54
|
-
normalizer: "dynaudnorm=g=101",
|
|
55
|
-
normalizer2: "acompressor",
|
|
56
|
-
surrounding: "surround",
|
|
57
|
-
pulsator: "apulsator=hz=1",
|
|
58
|
-
subboost: "asubboost",
|
|
59
|
-
karaoke: "stereotools=mlev=0.03",
|
|
60
|
-
flanger: "flanger",
|
|
61
|
-
gate: "agate",
|
|
62
|
-
haas: "haas",
|
|
63
|
-
mcompand: "mcompand",
|
|
64
|
-
mono: "pan=mono|c0=.5*c0+.5*c1",
|
|
65
|
-
mstlr: "stereotools=mode=ms>lr",
|
|
66
|
-
mstrr: "stereotools=mode=ms>rr",
|
|
67
|
-
compressor: "compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6",
|
|
68
|
-
expander: "compand=attacks=0:points=-80/-169|-54/-80|-49.5/-64.6|-41.1/-41.1|-25.8/-15|-10.8/-4.5|0/0|20/8.3",
|
|
69
|
-
softlimiter: "compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8",
|
|
70
|
-
chorus: "chorus=0.7:0.9:55:0.4:0.25:2",
|
|
71
|
-
chorus2d: "chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3",
|
|
72
|
-
chorus3d: "chorus=0.5:0.9:50|60|40:0.4|0.32|0.3:0.25|0.4|0.3:2|2.3|1.3",
|
|
73
|
-
fadein: "afade=t=in:ss=0:d=10",
|
|
74
|
-
dim: `afftfilt="'real=re * (1-clip((b/nb)*b,0,1))':imag='im * (1-clip((b/nb)*b,0,1))'"`,
|
|
75
|
-
earrape: "channelsplit,sidechaingate=level_in=64",
|
|
76
|
-
*[Symbol.iterator]() {
|
|
77
|
-
for (const [k, v] of Object.entries(this)) {
|
|
78
|
-
if (typeof this[k] === "string")
|
|
79
|
-
yield { name: k, value: v };
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
get names() {
|
|
83
|
-
return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this[p] !== "function");
|
|
84
|
-
},
|
|
85
|
-
get length() {
|
|
86
|
-
return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this[p] !== "function").length;
|
|
87
|
-
},
|
|
88
|
-
toString() {
|
|
89
|
-
return this.names.map((m) => this[m]).join(","); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
90
|
-
},
|
|
91
|
-
create(filter) {
|
|
92
|
-
if (!filter || !Array.isArray(filter))
|
|
93
|
-
return this.toString();
|
|
94
|
-
return filter
|
|
95
|
-
.filter((predicate) => typeof predicate === "string")
|
|
96
|
-
.map((m) => this[m])
|
|
97
|
-
.join(",");
|
|
98
|
-
},
|
|
99
|
-
define(filterName, value) {
|
|
100
|
-
if (typeof this[filterName] && typeof this[filterName] === "function")
|
|
101
|
-
return;
|
|
102
|
-
this[filterName] = value;
|
|
103
|
-
},
|
|
104
|
-
defineBulk(filterArray) {
|
|
105
|
-
filterArray.forEach((arr) => this.define(arr.name, arr.value));
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
exports.AudioFilters = FilterList;
|
|
109
|
-
exports.default = FilterList;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QueryResolver = void 0;
|
|
4
|
-
const ytdl_core_1 = require("ytdl-core");
|
|
5
|
-
const youtube_sr_1 = require("youtube-sr");
|
|
6
|
-
const types_1 = require("../types/types");
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
const soundcloud_scraper_1 = require("soundcloud-scraper");
|
|
10
|
-
// scary things below *sigh*
|
|
11
|
-
const spotifySongRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:track\/|\?uri=spotify:track:)((\w|-){22})/;
|
|
12
|
-
const spotifyPlaylistRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:playlist\/|\?uri=spotify:playlist:)((\w|-){22})/;
|
|
13
|
-
const spotifyAlbumRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:album\/|\?uri=spotify:album:)((\w|-){22})/;
|
|
14
|
-
const vimeoRegex = /(http|https)?:\/\/(www\.|player\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|video\/|)(\d+)(?:|\/\?)/;
|
|
15
|
-
const facebookRegex = /(https?:\/\/)(www\.|m\.)?(facebook|fb).com\/.*\/videos\/.*/;
|
|
16
|
-
const reverbnationRegex = /https:\/\/(www.)?reverbnation.com\/(.+)\/song\/(.+)/;
|
|
17
|
-
const attachmentRegex = /^(?:(?:https?|ftp):\/\/)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?$/;
|
|
18
|
-
// scary things above *sigh*
|
|
19
|
-
class QueryResolver {
|
|
20
|
-
/**
|
|
21
|
-
* Query resolver
|
|
22
|
-
*/
|
|
23
|
-
constructor() { } // eslint-disable-line @typescript-eslint/no-empty-function
|
|
24
|
-
/**
|
|
25
|
-
* Resolves the given search query
|
|
26
|
-
* @param {string} query The query
|
|
27
|
-
* @returns {QueryType}
|
|
28
|
-
*/
|
|
29
|
-
static resolve(query) {
|
|
30
|
-
if ((0, soundcloud_scraper_1.validateURL)(query, "track"))
|
|
31
|
-
return types_1.QueryType.SOUNDCLOUD_TRACK;
|
|
32
|
-
if ((0, soundcloud_scraper_1.validateURL)(query, "playlist") || query.includes("/sets/"))
|
|
33
|
-
return types_1.QueryType.SOUNDCLOUD_PLAYLIST;
|
|
34
|
-
if (youtube_sr_1.YouTube.isPlaylist(query))
|
|
35
|
-
return types_1.QueryType.YOUTUBE_PLAYLIST;
|
|
36
|
-
if ((0, ytdl_core_1.validateID)(query) || (0, ytdl_core_1.validateURL)(query))
|
|
37
|
-
return types_1.QueryType.YOUTUBE_VIDEO;
|
|
38
|
-
if (spotifySongRegex.test(query))
|
|
39
|
-
return types_1.QueryType.SPOTIFY_SONG;
|
|
40
|
-
if (spotifyPlaylistRegex.test(query))
|
|
41
|
-
return types_1.QueryType.SPOTIFY_PLAYLIST;
|
|
42
|
-
if (spotifyAlbumRegex.test(query))
|
|
43
|
-
return types_1.QueryType.SPOTIFY_ALBUM;
|
|
44
|
-
if (vimeoRegex.test(query))
|
|
45
|
-
return types_1.QueryType.VIMEO;
|
|
46
|
-
if (facebookRegex.test(query))
|
|
47
|
-
return types_1.QueryType.FACEBOOK;
|
|
48
|
-
if (reverbnationRegex.test(query))
|
|
49
|
-
return types_1.QueryType.REVERBNATION;
|
|
50
|
-
if (attachmentRegex.test(query))
|
|
51
|
-
return types_1.QueryType.ARBITRARY;
|
|
52
|
-
return types_1.QueryType.YOUTUBE_SEARCH;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Parses vimeo id from url
|
|
56
|
-
* @param {string} query The query
|
|
57
|
-
* @returns {string}
|
|
58
|
-
*/
|
|
59
|
-
static getVimeoID(query) {
|
|
60
|
-
return QueryResolver.resolve(query) === types_1.QueryType.VIMEO
|
|
61
|
-
? query
|
|
62
|
-
.split("/")
|
|
63
|
-
.filter((x) => !!x)
|
|
64
|
-
.pop()
|
|
65
|
-
: null;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.QueryResolver = QueryResolver;
|
package/dist/utils/Util.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
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
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Util = void 0;
|
|
27
|
-
class Util {
|
|
28
|
-
/**
|
|
29
|
-
* Utils
|
|
30
|
-
*/
|
|
31
|
-
constructor() { } // eslint-disable-line @typescript-eslint/no-empty-function
|
|
32
|
-
/**
|
|
33
|
-
* Creates duration string
|
|
34
|
-
* @param {object} durObj The duration object
|
|
35
|
-
* @returns {string}
|
|
36
|
-
*/
|
|
37
|
-
static durationString(durObj) {
|
|
38
|
-
return Object.values(durObj)
|
|
39
|
-
.map((m) => (isNaN(m) ? 0 : m))
|
|
40
|
-
.join(":");
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Parses milliseconds to consumable time object
|
|
44
|
-
* @param {number} milliseconds The time in ms
|
|
45
|
-
* @returns {TimeData}
|
|
46
|
-
*/
|
|
47
|
-
static parseMS(milliseconds) {
|
|
48
|
-
const round = milliseconds > 0 ? Math.floor : Math.ceil;
|
|
49
|
-
return {
|
|
50
|
-
days: round(milliseconds / 86400000),
|
|
51
|
-
hours: round(milliseconds / 3600000) % 24,
|
|
52
|
-
minutes: round(milliseconds / 60000) % 60,
|
|
53
|
-
seconds: round(milliseconds / 1000) % 60
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Builds time code
|
|
58
|
-
* @param {TimeData} duration The duration object
|
|
59
|
-
* @returns {string}
|
|
60
|
-
*/
|
|
61
|
-
static buildTimeCode(duration) {
|
|
62
|
-
const items = Object.keys(duration);
|
|
63
|
-
const required = ["days", "hours", "minutes", "seconds"];
|
|
64
|
-
const parsed = items.filter((x) => required.includes(x)).map((m) => duration[m]);
|
|
65
|
-
const final = parsed
|
|
66
|
-
.slice(parsed.findIndex((x) => x !== 0))
|
|
67
|
-
.map((x) => x.toString().padStart(2, "0"))
|
|
68
|
-
.join(":");
|
|
69
|
-
return final.length <= 3 ? `0:${final.padStart(2, "0") || 0}` : final;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Picks last item of the given array
|
|
73
|
-
* @param {any[]} arr The array
|
|
74
|
-
* @returns {any}
|
|
75
|
-
*/
|
|
76
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
|
-
static last(arr) {
|
|
78
|
-
if (!Array.isArray(arr))
|
|
79
|
-
return;
|
|
80
|
-
return arr[arr.length - 1];
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Checks if the voice channel is empty
|
|
84
|
-
* @param {VoiceChannel|StageChannel} channel The voice channel
|
|
85
|
-
* @returns {boolean}
|
|
86
|
-
*/
|
|
87
|
-
static isVoiceEmpty(channel) {
|
|
88
|
-
return channel.members.filter((member) => !member.user.bot).size === 0;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Safer require
|
|
92
|
-
* @param {string} id Node require id
|
|
93
|
-
* @returns {any}
|
|
94
|
-
*/
|
|
95
|
-
static require(id) {
|
|
96
|
-
try {
|
|
97
|
-
return require(id);
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Asynchronous timeout
|
|
105
|
-
* @param {number} time The time in ms to wait
|
|
106
|
-
* @returns {Promise<unknown>}
|
|
107
|
-
*/
|
|
108
|
-
static wait(time) {
|
|
109
|
-
return new Promise((r) => setTimeout(r, time).unref());
|
|
110
|
-
}
|
|
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
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.Util = Util;
|