discord-player 5.3.2-dev.2 → 5.3.2

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.
@@ -1,68 +1,68 @@
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
- // #region 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
- // #endregion 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;
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
+ // #region 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
+ // #endregion 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;
@@ -1,135 +1,136 @@
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
- if (isNaN(milliseconds))
49
- milliseconds = 0;
50
- const round = milliseconds > 0 ? Math.floor : Math.ceil;
51
- return {
52
- days: round(milliseconds / 86400000),
53
- hours: round(milliseconds / 3600000) % 24,
54
- minutes: round(milliseconds / 60000) % 60,
55
- seconds: round(milliseconds / 1000) % 60
56
- };
57
- }
58
- /**
59
- * Builds time code
60
- * @param {TimeData} duration The duration object
61
- * @returns {string}
62
- */
63
- static buildTimeCode(duration) {
64
- const items = Object.keys(duration);
65
- const required = ["days", "hours", "minutes", "seconds"];
66
- const parsed = items.filter((x) => required.includes(x)).map((m) => duration[m]);
67
- const final = parsed
68
- .slice(parsed.findIndex((x) => x !== 0))
69
- .map((x) => x.toString().padStart(2, "0"))
70
- .join(":");
71
- return final.length <= 3 ? `0:${final.padStart(2, "0") || 0}` : final;
72
- }
73
- /**
74
- * Picks last item of the given array
75
- * @param {any[]} arr The array
76
- * @returns {any}
77
- */
78
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
- static last(arr) {
80
- if (!Array.isArray(arr))
81
- return;
82
- return arr[arr.length - 1];
83
- }
84
- /**
85
- * Checks if the voice channel is empty
86
- * @param {VoiceChannel|StageChannel} channel The voice channel
87
- * @returns {boolean}
88
- */
89
- static isVoiceEmpty(channel) {
90
- return channel.members.filter((member) => !member.user.bot).size === 0;
91
- }
92
- /**
93
- * Safer require
94
- * @param {string} id Node require id
95
- * @returns {any}
96
- */
97
- static require(id) {
98
- try {
99
- return require(id);
100
- }
101
- catch {
102
- return null;
103
- }
104
- }
105
- /**
106
- * Asynchronous timeout
107
- * @param {number} time The time in ms to wait
108
- * @returns {Promise<unknown>}
109
- */
110
- static wait(time) {
111
- return new Promise((r) => setTimeout(r, time).unref());
112
- }
113
- static noop() { } // eslint-disable-line @typescript-eslint/no-empty-function
114
- static async getFetch() {
115
- if ("fetch" in globalThis)
116
- return globalThis.fetch;
117
- for (const lib of ["undici", "node-fetch"]) {
118
- try {
119
- return await Promise.resolve().then(() => __importStar(require(lib))).then((res) => res.fetch || res.default?.fetch || res.default);
120
- }
121
- catch {
122
- try {
123
- // eslint-disable-next-line
124
- const res = require(lib);
125
- if (res)
126
- return res.fetch || res.default?.fetch || res.default;
127
- }
128
- catch {
129
- // no?
130
- }
131
- }
132
- }
133
- }
134
- }
135
- exports.Util = Util;
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
+ const promises_1 = require("timers/promises");
28
+ class Util {
29
+ /**
30
+ * Utils
31
+ */
32
+ constructor() { } // eslint-disable-line @typescript-eslint/no-empty-function
33
+ /**
34
+ * Creates duration string
35
+ * @param {object} durObj The duration object
36
+ * @returns {string}
37
+ */
38
+ static durationString(durObj) {
39
+ return Object.values(durObj)
40
+ .map((m) => (isNaN(m) ? 0 : m))
41
+ .join(":");
42
+ }
43
+ /**
44
+ * Parses milliseconds to consumable time object
45
+ * @param {number} milliseconds The time in ms
46
+ * @returns {TimeData}
47
+ */
48
+ static parseMS(milliseconds) {
49
+ if (isNaN(milliseconds))
50
+ milliseconds = 0;
51
+ const round = milliseconds > 0 ? Math.floor : Math.ceil;
52
+ return {
53
+ days: round(milliseconds / 86400000),
54
+ hours: round(milliseconds / 3600000) % 24,
55
+ minutes: round(milliseconds / 60000) % 60,
56
+ seconds: round(milliseconds / 1000) % 60
57
+ };
58
+ }
59
+ /**
60
+ * Builds time code
61
+ * @param {TimeData} duration The duration object
62
+ * @returns {string}
63
+ */
64
+ static buildTimeCode(duration) {
65
+ const items = Object.keys(duration);
66
+ const required = ["days", "hours", "minutes", "seconds"];
67
+ const parsed = items.filter((x) => required.includes(x)).map((m) => duration[m]);
68
+ const final = parsed
69
+ .slice(parsed.findIndex((x) => x !== 0))
70
+ .map((x) => x.toString().padStart(2, "0"))
71
+ .join(":");
72
+ return final.length <= 3 ? `0:${final.padStart(2, "0") || 0}` : final;
73
+ }
74
+ /**
75
+ * Picks last item of the given array
76
+ * @param {any[]} arr The array
77
+ * @returns {any}
78
+ */
79
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
+ static last(arr) {
81
+ if (!Array.isArray(arr))
82
+ return;
83
+ return arr[arr.length - 1];
84
+ }
85
+ /**
86
+ * Checks if the voice channel is empty
87
+ * @param {VoiceChannel|StageChannel} channel The voice channel
88
+ * @returns {boolean}
89
+ */
90
+ static isVoiceEmpty(channel) {
91
+ return channel.members.filter((member) => !member.user.bot).size === 0;
92
+ }
93
+ /**
94
+ * Safer require
95
+ * @param {string} id Node require id
96
+ * @returns {any}
97
+ */
98
+ static require(id) {
99
+ try {
100
+ return require(id);
101
+ }
102
+ catch {
103
+ return null;
104
+ }
105
+ }
106
+ /**
107
+ * Asynchronous timeout
108
+ * @param {number} time The time in ms to wait
109
+ * @returns {Promise<unknown>}
110
+ */
111
+ static wait(time) {
112
+ return (0, promises_1.setTimeout)(time, undefined, { ref: false });
113
+ }
114
+ static noop() { } // eslint-disable-line @typescript-eslint/no-empty-function
115
+ static async getFetch() {
116
+ if ("fetch" in globalThis)
117
+ return globalThis.fetch;
118
+ for (const lib of ["node-fetch", "undici"]) {
119
+ try {
120
+ return await Promise.resolve().then(() => __importStar(require(lib))).then((res) => res.fetch || res.default?.fetch || res.default);
121
+ }
122
+ catch {
123
+ try {
124
+ // eslint-disable-next-line
125
+ const res = require(lib);
126
+ if (res)
127
+ return res.fetch || res.default?.fetch || res.default;
128
+ }
129
+ catch {
130
+ // no?
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
136
+ exports.Util = Util;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discord-player",
3
- "version": "5.3.2-dev.2",
3
+ "version": "5.3.2",
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",