magmastream 2.10.2-dev.3 → 2.10.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.
- package/dist/index.d.ts +3912 -20
- package/dist/structures/Manager.js +8 -9
- package/dist/structures/Node.js +1 -1
- package/dist/structures/Rest.js +2 -7
- package/dist/wrappers/discord.js.js +1 -1
- package/package.json +8 -6
- package/dist/config/blockedWords.d.ts +0 -1
- package/dist/statestorage/JsonQueue.d.ts +0 -173
- package/dist/statestorage/MemoryQueue.d.ts +0 -154
- package/dist/statestorage/RedisQueue.d.ts +0 -178
- package/dist/structures/Enums.d.ts +0 -313
- package/dist/structures/Filters.d.ts +0 -352
- package/dist/structures/MagmastreamError.d.ts +0 -14
- package/dist/structures/Manager.d.ts +0 -260
- package/dist/structures/Node.d.ts +0 -390
- package/dist/structures/Player.d.ts +0 -347
- package/dist/structures/Plugin.d.ts +0 -23
- package/dist/structures/Rest.d.ts +0 -95
- package/dist/structures/Types.d.ts +0 -1359
- package/dist/structures/Utils.d.ts +0 -169
- package/dist/utils/filtersEqualizers.d.ts +0 -16
- package/dist/utils/managerCheck.d.ts +0 -7
- package/dist/utils/nodeCheck.d.ts +0 -7
- package/dist/utils/playerCheck.d.ts +0 -7
- package/dist/wrappers/cloudstorm.d.ts +0 -27
- package/dist/wrappers/discord.js.d.ts +0 -14
- package/dist/wrappers/discordeno.d.ts +0 -18
- package/dist/wrappers/eris.d.ts +0 -14
- package/dist/wrappers/oceanic.d.ts +0 -14
- package/dist/wrappers/seyfert.d.ts +0 -36
|
@@ -16,6 +16,11 @@ const Enums_1 = require("./Enums");
|
|
|
16
16
|
const package_json_1 = require("../../package.json");
|
|
17
17
|
const MagmastreamError_1 = require("./MagmastreamError");
|
|
18
18
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
19
|
+
function escapeRegExp(value) {
|
|
20
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
21
|
+
}
|
|
22
|
+
const YOUTUBE_URL_PATTERN = /(youtube\.com|youtu\.be)/;
|
|
23
|
+
const BLOCKED_WORDS_PATTERN = new RegExp(`\\b(${blockedWords_1.blockedWords.map(escapeRegExp).join("|")})\\b`, "gi");
|
|
19
24
|
/**
|
|
20
25
|
* The main hub for interacting with Lavalink and using Magmastream.
|
|
21
26
|
*/
|
|
@@ -258,7 +263,7 @@ class Manager extends events_1.EventEmitter {
|
|
|
258
263
|
}
|
|
259
264
|
if (this.options.normalizeYouTubeTitles && "tracks" in result) {
|
|
260
265
|
const processTrack = (track) => {
|
|
261
|
-
if (
|
|
266
|
+
if (!YOUTUBE_URL_PATTERN.test(track.uri))
|
|
262
267
|
return track;
|
|
263
268
|
const { cleanTitle, cleanAuthor } = this.parseYouTubeTitle(track.title, track.author);
|
|
264
269
|
track.title = cleanTitle;
|
|
@@ -267,7 +272,7 @@ class Manager extends events_1.EventEmitter {
|
|
|
267
272
|
};
|
|
268
273
|
result.tracks = result.tracks.map(processTrack);
|
|
269
274
|
if ("playlist" in result && result.playlist) {
|
|
270
|
-
result.playlist.tracks = result.
|
|
275
|
+
result.playlist.tracks = result.tracks;
|
|
271
276
|
}
|
|
272
277
|
}
|
|
273
278
|
const summary = "tracks" in result ? result.tracks.map((t) => Object.fromEntries(Object.entries(t).filter(([key]) => key !== "requester"))) : [];
|
|
@@ -780,9 +785,7 @@ class Manager extends events_1.EventEmitter {
|
|
|
780
785
|
const cleanAuthor = originalAuthor.replace("- Topic", "").trim();
|
|
781
786
|
title = title.replace("Topic -", "").trim();
|
|
782
787
|
// Remove blocked words and phrases
|
|
783
|
-
|
|
784
|
-
const blockedWordsPattern = new RegExp(`\\b(${escapedBlockedWords.join("|")})\\b`, "gi");
|
|
785
|
-
title = title.replace(blockedWordsPattern, "").trim();
|
|
788
|
+
title = title.replace(BLOCKED_WORDS_PATTERN, "").trim();
|
|
786
789
|
// Remove empty brackets and balance remaining brackets
|
|
787
790
|
title = title
|
|
788
791
|
.replace(/[([{]\s*[)\]}]/g, "") // Empty brackets
|
|
@@ -847,10 +850,6 @@ class Manager extends events_1.EventEmitter {
|
|
|
847
850
|
* @param string - The string to escape.
|
|
848
851
|
* @returns The escaped string.
|
|
849
852
|
*/
|
|
850
|
-
escapeRegExp(string) {
|
|
851
|
-
// Replace special regex characters with their escaped counterparts
|
|
852
|
-
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
853
|
-
}
|
|
854
853
|
/**
|
|
855
854
|
* Checks if the given data is a voice update.
|
|
856
855
|
* @param data The data to check.
|
package/dist/structures/Node.js
CHANGED
|
@@ -1125,7 +1125,7 @@ class Node {
|
|
|
1125
1125
|
});
|
|
1126
1126
|
}
|
|
1127
1127
|
try {
|
|
1128
|
-
await this.rest.put(`/v4/sessions/${this.sessionId}/players/${player.guildId}/sponsorblock/categories`,
|
|
1128
|
+
await this.rest.put(`/v4/sessions/${this.sessionId}/players/${player.guildId}/sponsorblock/categories`, segments.map((v) => v.toLowerCase()));
|
|
1129
1129
|
}
|
|
1130
1130
|
catch (err) {
|
|
1131
1131
|
throw err instanceof MagmastreamError_1.MagmaStreamError
|
package/dist/structures/Rest.js
CHANGED
|
@@ -104,8 +104,6 @@ class Rest {
|
|
|
104
104
|
*/
|
|
105
105
|
async request(method, endpoint, body) {
|
|
106
106
|
this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[REST] ${method} request to ${endpoint} with body: ${Utils_1.JSONUtils.safe(body, 2)}`);
|
|
107
|
-
const controller = new AbortController();
|
|
108
|
-
const timeoutHandle = setTimeout(() => controller.abort(), this.node.options.apiRequestTimeoutMs);
|
|
109
107
|
let response = null;
|
|
110
108
|
try {
|
|
111
109
|
response = await (0, undici_1.fetch)(this.url + endpoint, {
|
|
@@ -115,11 +113,11 @@ class Rest {
|
|
|
115
113
|
Authorization: this.password,
|
|
116
114
|
},
|
|
117
115
|
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
118
|
-
signal:
|
|
116
|
+
signal: AbortSignal.timeout(this.node.options.apiRequestTimeoutMs),
|
|
119
117
|
});
|
|
120
118
|
}
|
|
121
119
|
catch (e) {
|
|
122
|
-
const isTimeout = e instanceof Error && e.name === "AbortError";
|
|
120
|
+
const isTimeout = e instanceof Error && (e.name === "AbortError" || e.name === "TimeoutError");
|
|
123
121
|
const message = e instanceof Error ? e.message : "Unknown error";
|
|
124
122
|
const error = new MagmastreamError_1.MagmaStreamError({
|
|
125
123
|
code: Enums_1.MagmaStreamErrorCode.REST_REQUEST_FAILED,
|
|
@@ -128,9 +126,6 @@ class Rest {
|
|
|
128
126
|
this.manager.emit(Enums_1.ManagerEventTypes.NodeError, this.node, error);
|
|
129
127
|
return null;
|
|
130
128
|
}
|
|
131
|
-
finally {
|
|
132
|
-
clearTimeout(timeoutHandle);
|
|
133
|
-
}
|
|
134
129
|
const { status } = response;
|
|
135
130
|
const data = status !== 204 ? await response.json() : null;
|
|
136
131
|
if (status >= 200 && status < 300) {
|
|
@@ -15,7 +15,7 @@ class DiscordJSManager extends Manager_1.Manager {
|
|
|
15
15
|
constructor(client, options) {
|
|
16
16
|
super(options, true);
|
|
17
17
|
this.client = client;
|
|
18
|
-
const { version: djsVersion } = moduleRequire("discord.js
|
|
18
|
+
const { version: djsVersion } = moduleRequire("discord.js");
|
|
19
19
|
const [major, minor] = djsVersion.split(".").map(Number);
|
|
20
20
|
if (!this.client.options.intents.has(GUILD_VOICE_STATES_INTENT)) {
|
|
21
21
|
throw new MagmastreamError_1.MagmaStreamError({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magmastream",
|
|
3
|
-
"version": "2.10.2
|
|
3
|
+
"version": "2.10.2",
|
|
4
4
|
"description": "A user-friendly Lavalink client designed for NodeJS.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"prepare": "npm run build",
|
|
11
|
+
"prepare": "npm run build && npm run types",
|
|
12
12
|
"build": "tsc",
|
|
13
13
|
"types": "rtb --dist dist",
|
|
14
14
|
"format": "prettier --write .",
|
|
@@ -16,14 +16,16 @@
|
|
|
16
16
|
"lint": "eslint \"src/**/*.{ts,js}\"",
|
|
17
17
|
"lint:fix": "eslint --fix \"src/**/*.{ts,js}\"",
|
|
18
18
|
"ci": "run-s format:check lint build types",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"version:alpha": "node scripts/prerelease-version.cjs alpha",
|
|
20
|
+
"version:dev": "node scripts/prerelease-version.cjs dev",
|
|
21
|
+
"release:alpha": "npm run format && npm run lint:fix && npm run ci && npm run version:alpha && npm publish --tag alpha && git push && git push --follow-tags",
|
|
22
|
+
"release:dev": "npm run format && npm run lint:fix && npm run ci && npm run version:dev && npm publish --tag dev && git push && git push --follow-tags"
|
|
21
23
|
},
|
|
22
24
|
"devDependencies": {
|
|
23
25
|
"@favware/rollup-type-bundler": "^4.0.0",
|
|
24
26
|
"@types/jsdom": "^28.0.0",
|
|
25
27
|
"@types/lodash": "^4.17.24",
|
|
26
|
-
"@types/node": "^25.
|
|
28
|
+
"@types/node": "^25.9.1",
|
|
27
29
|
"@types/ws": "^8.18.1",
|
|
28
30
|
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
29
31
|
"@typescript-eslint/parser": "^8.56.1",
|
|
@@ -104,4 +106,4 @@
|
|
|
104
106
|
"homepage": "https://docs.magmastream.com",
|
|
105
107
|
"author": "Abel Purnwasy",
|
|
106
108
|
"license": "Apache-2.0"
|
|
107
|
-
}
|
|
109
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const blockedWords: string[];
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { Manager } from "../structures/Manager";
|
|
2
|
-
import { IQueue, Track } from "../structures/Types";
|
|
3
|
-
/**
|
|
4
|
-
* The player's queue, the `current` property is the currently playing track, think of the rest as the up-coming tracks.
|
|
5
|
-
*/
|
|
6
|
-
export declare class JsonQueue implements IQueue {
|
|
7
|
-
readonly guildId: string;
|
|
8
|
-
readonly manager: Manager;
|
|
9
|
-
/**
|
|
10
|
-
* The base path for the queue files.
|
|
11
|
-
*/
|
|
12
|
-
private basePath;
|
|
13
|
-
/**
|
|
14
|
-
* Whether the queue has been destroyed.
|
|
15
|
-
*/
|
|
16
|
-
private destroyed;
|
|
17
|
-
/**
|
|
18
|
-
* @param guildId The guild ID.
|
|
19
|
-
* @param manager The manager.
|
|
20
|
-
*/
|
|
21
|
-
constructor(guildId: string, manager: Manager);
|
|
22
|
-
/**
|
|
23
|
-
* @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
|
|
24
|
-
* @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
|
|
25
|
-
*/
|
|
26
|
-
add(track: Track | Track[], offset?: number): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* @param track The track to add.
|
|
29
|
-
*/
|
|
30
|
-
addPrevious(track: Track | Track[]): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Clears the queue.
|
|
33
|
-
*/
|
|
34
|
-
clear(): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Clears the previous tracks.
|
|
37
|
-
*/
|
|
38
|
-
clearPrevious(): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Removes the first track from the queue.
|
|
41
|
-
*/
|
|
42
|
-
dequeue(): Promise<Track | undefined>;
|
|
43
|
-
/**
|
|
44
|
-
* Destroys the queue and releases all resources.
|
|
45
|
-
* After calling this method, the queue must not be used again.
|
|
46
|
-
*/
|
|
47
|
-
destroy(): Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* @returns The total duration of the queue.
|
|
50
|
-
*/
|
|
51
|
-
duration(): Promise<number>;
|
|
52
|
-
/**
|
|
53
|
-
* Adds a track to the front of the queue.
|
|
54
|
-
*/
|
|
55
|
-
enqueueFront(track: Track | Track[]): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* Tests whether all elements in the queue pass the test implemented by the provided function.
|
|
58
|
-
*/
|
|
59
|
-
everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
|
|
60
|
-
/**
|
|
61
|
-
* Filters the queue.
|
|
62
|
-
*/
|
|
63
|
-
filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
|
|
64
|
-
/**
|
|
65
|
-
* Finds the first track in the queue that satisfies the provided testing function.
|
|
66
|
-
*/
|
|
67
|
-
findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
|
|
68
|
-
/**
|
|
69
|
-
* @returns The current track.
|
|
70
|
-
*/
|
|
71
|
-
getCurrent(): Promise<Track | null>;
|
|
72
|
-
/**
|
|
73
|
-
* @returns The previous tracks.
|
|
74
|
-
*/
|
|
75
|
-
getPrevious(): Promise<Track[]>;
|
|
76
|
-
/**
|
|
77
|
-
* @returns The tracks in the queue from start to end.
|
|
78
|
-
*/
|
|
79
|
-
getSlice(start?: number, end?: number): Promise<Track[]>;
|
|
80
|
-
/**
|
|
81
|
-
* @returns The tracks in the queue.
|
|
82
|
-
*/
|
|
83
|
-
getTracks(): Promise<Track[]>;
|
|
84
|
-
/**
|
|
85
|
-
* Maps the queue to a new array.
|
|
86
|
-
*/
|
|
87
|
-
mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
|
|
88
|
-
/**
|
|
89
|
-
* Modifies the queue at the specified index.
|
|
90
|
-
*/
|
|
91
|
-
modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise<Track[]>;
|
|
92
|
-
/**
|
|
93
|
-
* @returns The newest track.
|
|
94
|
-
*/
|
|
95
|
-
popPrevious(): Promise<Track | null>;
|
|
96
|
-
/**
|
|
97
|
-
* Removes a track from the queue.
|
|
98
|
-
* @param position The position to remove the track at.
|
|
99
|
-
* @param end The end position to remove the track at.
|
|
100
|
-
*/
|
|
101
|
-
remove(position?: number): Promise<Track[]>;
|
|
102
|
-
remove(start: number, end: number): Promise<Track[]>;
|
|
103
|
-
/**
|
|
104
|
-
* Shuffles the queue by round-robin.
|
|
105
|
-
*/
|
|
106
|
-
roundRobinShuffle(): Promise<void>;
|
|
107
|
-
/**
|
|
108
|
-
* @param track The track to set.
|
|
109
|
-
*/
|
|
110
|
-
setCurrent(track: Track | null): Promise<void>;
|
|
111
|
-
/**
|
|
112
|
-
* @param track The track to set.
|
|
113
|
-
*/
|
|
114
|
-
setPrevious(track: Track | Track[]): Promise<void>;
|
|
115
|
-
/**
|
|
116
|
-
* Shuffles the queue.
|
|
117
|
-
*/
|
|
118
|
-
shuffle(): Promise<void>;
|
|
119
|
-
/**
|
|
120
|
-
* @returns The size of the queue.
|
|
121
|
-
*/
|
|
122
|
-
size(): Promise<number>;
|
|
123
|
-
/**
|
|
124
|
-
* Tests whether at least one element in the queue passes the test implemented by the provided function.
|
|
125
|
-
*/
|
|
126
|
-
someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
|
|
127
|
-
/**
|
|
128
|
-
* @returns The total size of the queue.
|
|
129
|
-
*/
|
|
130
|
-
totalSize(): Promise<number>;
|
|
131
|
-
/**
|
|
132
|
-
* Shuffles the queue by user.
|
|
133
|
-
*/
|
|
134
|
-
userBlockShuffle(): Promise<void>;
|
|
135
|
-
/**
|
|
136
|
-
* @returns The current path.
|
|
137
|
-
*/
|
|
138
|
-
private get currentPath();
|
|
139
|
-
/**
|
|
140
|
-
* @param filePath The file path.
|
|
141
|
-
*/
|
|
142
|
-
private deleteFile;
|
|
143
|
-
/**
|
|
144
|
-
* Ensures the directory exists.
|
|
145
|
-
*/
|
|
146
|
-
private ensureDir;
|
|
147
|
-
/**
|
|
148
|
-
* @returns The queue.
|
|
149
|
-
*/
|
|
150
|
-
private getQueue;
|
|
151
|
-
/**
|
|
152
|
-
* @returns The previous path.
|
|
153
|
-
*/
|
|
154
|
-
private get previousPath();
|
|
155
|
-
/**
|
|
156
|
-
* @returns The queue path.
|
|
157
|
-
*/
|
|
158
|
-
private get queuePath();
|
|
159
|
-
/**
|
|
160
|
-
* @param filePath The file path.
|
|
161
|
-
* @returns The JSON data.
|
|
162
|
-
*/
|
|
163
|
-
private readJSON;
|
|
164
|
-
/**
|
|
165
|
-
* @param queue The queue.
|
|
166
|
-
*/
|
|
167
|
-
private setQueue;
|
|
168
|
-
/**
|
|
169
|
-
* @param filePath The file path.
|
|
170
|
-
* @param data The data to write.
|
|
171
|
-
*/
|
|
172
|
-
private writeJSON;
|
|
173
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { Manager } from "../structures/Manager";
|
|
2
|
-
import { IQueue, Track } from "../structures/Types";
|
|
3
|
-
/**
|
|
4
|
-
* The player's queue, the `current` property is the currently playing track, think of the rest as the up-coming tracks.
|
|
5
|
-
*/
|
|
6
|
-
export declare class MemoryQueue extends Array<Track> implements IQueue {
|
|
7
|
-
/** The current track */
|
|
8
|
-
current: Track | null;
|
|
9
|
-
/** The previous tracks */
|
|
10
|
-
previous: Track[];
|
|
11
|
-
/** The Manager instance. */
|
|
12
|
-
manager: Manager;
|
|
13
|
-
/** The guild ID property. */
|
|
14
|
-
guildId: string;
|
|
15
|
-
/**
|
|
16
|
-
* Whether the queue has been destroyed.
|
|
17
|
-
*/
|
|
18
|
-
private destroyed;
|
|
19
|
-
/**
|
|
20
|
-
* Constructs a new Queue.
|
|
21
|
-
* @param guildId The guild ID.
|
|
22
|
-
* @param manager The Manager instance.
|
|
23
|
-
*/
|
|
24
|
-
constructor(guildId: string, manager: Manager);
|
|
25
|
-
/**
|
|
26
|
-
* Adds a track to the queue.
|
|
27
|
-
* @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
|
|
28
|
-
* @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
|
|
29
|
-
*/
|
|
30
|
-
add(track: Track | Track[], offset?: number): void;
|
|
31
|
-
/**
|
|
32
|
-
* Adds a track to the previous tracks.
|
|
33
|
-
* @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
|
|
34
|
-
*/
|
|
35
|
-
addPrevious(track: Track | Track[]): void;
|
|
36
|
-
/**
|
|
37
|
-
* Clears the queue.
|
|
38
|
-
* This will remove all tracks from the queue and emit a state update event.
|
|
39
|
-
*/
|
|
40
|
-
clear(): void;
|
|
41
|
-
/**
|
|
42
|
-
* Clears the previous tracks.
|
|
43
|
-
*/
|
|
44
|
-
clearPrevious(): void;
|
|
45
|
-
/**
|
|
46
|
-
* Removes the first element from the queue.
|
|
47
|
-
*/
|
|
48
|
-
dequeue(): Track | undefined;
|
|
49
|
-
/**
|
|
50
|
-
* Destroys the queue and releases all resources.
|
|
51
|
-
* After calling this method, the queue must not be used again.
|
|
52
|
-
*/
|
|
53
|
-
destroy(): void;
|
|
54
|
-
/**
|
|
55
|
-
* The total duration of the queue in milliseconds.
|
|
56
|
-
* This includes the duration of the currently playing track.
|
|
57
|
-
*/
|
|
58
|
-
duration(): number;
|
|
59
|
-
/**
|
|
60
|
-
* Adds the specified track or tracks to the front of the queue.
|
|
61
|
-
* @param track The track or tracks to add.
|
|
62
|
-
*/
|
|
63
|
-
enqueueFront(track: Track | Track[]): void;
|
|
64
|
-
/**
|
|
65
|
-
* @returns Whether all elements in the queue satisfy the provided testing function.
|
|
66
|
-
*/
|
|
67
|
-
everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): boolean;
|
|
68
|
-
/**
|
|
69
|
-
* @returns A new array with all elements that pass the test implemented by the provided function.
|
|
70
|
-
*/
|
|
71
|
-
filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Track[];
|
|
72
|
-
/**
|
|
73
|
-
* @returns The first element in the queue that satisfies the provided testing function.
|
|
74
|
-
*/
|
|
75
|
-
findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Track | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* @returns The current track.
|
|
78
|
-
*/
|
|
79
|
-
getCurrent(): Track | null;
|
|
80
|
-
/**
|
|
81
|
-
* @returns The previous tracks.
|
|
82
|
-
*/
|
|
83
|
-
getPrevious(): Track[];
|
|
84
|
-
/**
|
|
85
|
-
* @returns The tracks in the queue from start to end.
|
|
86
|
-
*/
|
|
87
|
-
getSlice(start?: number, end?: number): Track[];
|
|
88
|
-
/**
|
|
89
|
-
* @returns The tracks in the queue.
|
|
90
|
-
*/
|
|
91
|
-
getTracks(): Track[];
|
|
92
|
-
/**
|
|
93
|
-
* @returns A new array with the results of calling a provided function on every element in the queue.
|
|
94
|
-
*/
|
|
95
|
-
mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): T[];
|
|
96
|
-
/**
|
|
97
|
-
* Modifies the queue at the specified index.
|
|
98
|
-
* @param start The index at which to start modifying the queue.
|
|
99
|
-
* @param deleteCount The number of elements to remove from the queue.
|
|
100
|
-
* @param items The elements to add to the queue.
|
|
101
|
-
* @returns The modified queue.
|
|
102
|
-
*/
|
|
103
|
-
modifyAt(start: number, deleteCount?: number, ...items: Track[]): Track[];
|
|
104
|
-
/**
|
|
105
|
-
* @returns The newest track.
|
|
106
|
-
*/
|
|
107
|
-
popPrevious(): Track | null;
|
|
108
|
-
/**
|
|
109
|
-
* Removes track(s) from the queue.
|
|
110
|
-
* @param startOrPosition If a single number is provided, it will be treated as the position of the track to remove.
|
|
111
|
-
* If two numbers are provided, they will be used as the start and end of a range of tracks to remove.
|
|
112
|
-
* @param end Optional, end of the range of tracks to remove.
|
|
113
|
-
* @returns The removed track(s).
|
|
114
|
-
*/
|
|
115
|
-
remove(position?: number): Track[];
|
|
116
|
-
remove(start: number, end: number): Track[];
|
|
117
|
-
/**
|
|
118
|
-
* Shuffles the queue to play tracks requested by each user one by one.
|
|
119
|
-
*/
|
|
120
|
-
roundRobinShuffle(): void;
|
|
121
|
-
/**
|
|
122
|
-
* @param track The track to set.
|
|
123
|
-
*/
|
|
124
|
-
setCurrent(track: Track | null): void;
|
|
125
|
-
/**
|
|
126
|
-
* @param tracks The tracks to set.
|
|
127
|
-
*/
|
|
128
|
-
setPrevious(tracks: Track[]): void;
|
|
129
|
-
/**
|
|
130
|
-
* Shuffles the queue.
|
|
131
|
-
* This will randomize the order of the tracks in the queue and emit a state update event.
|
|
132
|
-
*/
|
|
133
|
-
shuffle(): void;
|
|
134
|
-
/**
|
|
135
|
-
* The size of tracks in the queue.
|
|
136
|
-
* This does not include the currently playing track.
|
|
137
|
-
* @returns The size of tracks in the queue.
|
|
138
|
-
*/
|
|
139
|
-
size(): number;
|
|
140
|
-
/**
|
|
141
|
-
* @returns Whether at least one element in the queue satisfies the provided testing function.
|
|
142
|
-
*/
|
|
143
|
-
someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): boolean;
|
|
144
|
-
/**
|
|
145
|
-
* The total size of tracks in the queue including the current track.
|
|
146
|
-
* This includes the current track if it is not null.
|
|
147
|
-
* @returns The total size of tracks in the queue including the current track.
|
|
148
|
-
*/
|
|
149
|
-
totalSize(): number;
|
|
150
|
-
/**
|
|
151
|
-
* Shuffles the queue to play tracks requested by each user one block at a time.
|
|
152
|
-
*/
|
|
153
|
-
userBlockShuffle(): void;
|
|
154
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { Manager } from "../structures/Manager";
|
|
2
|
-
import { IQueue, Track } from "../structures/Types";
|
|
3
|
-
/**
|
|
4
|
-
* The player's queue, the `current` property is the currently playing track, think of the rest as the up-coming tracks.
|
|
5
|
-
*/
|
|
6
|
-
export declare class RedisQueue implements IQueue {
|
|
7
|
-
readonly guildId: string;
|
|
8
|
-
readonly manager: Manager;
|
|
9
|
-
/**
|
|
10
|
-
* The prefix for the Redis keys.
|
|
11
|
-
*/
|
|
12
|
-
redisPrefix: string;
|
|
13
|
-
/**
|
|
14
|
-
* The Redis instance.
|
|
15
|
-
*/
|
|
16
|
-
private redis;
|
|
17
|
-
/**
|
|
18
|
-
* Whether the queue has been destroyed.
|
|
19
|
-
*/
|
|
20
|
-
private destroyed;
|
|
21
|
-
/**
|
|
22
|
-
* Constructs a new RedisQueue.
|
|
23
|
-
* @param guildId The guild ID.
|
|
24
|
-
* @param manager The Manager instance.
|
|
25
|
-
*/
|
|
26
|
-
constructor(guildId: string, manager: Manager);
|
|
27
|
-
/**
|
|
28
|
-
* Adds a track or tracks to the queue.
|
|
29
|
-
* @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
|
|
30
|
-
* @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
|
|
31
|
-
*/
|
|
32
|
-
add(track: Track | Track[], offset?: number): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* Adds a track or tracks to the previous tracks.
|
|
35
|
-
* @param track The track or tracks to add.
|
|
36
|
-
*/
|
|
37
|
-
addPrevious(track: Track | Track[]): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Clears the queue.
|
|
40
|
-
*/
|
|
41
|
-
clear(): Promise<void>;
|
|
42
|
-
/**
|
|
43
|
-
* Clears the previous tracks.
|
|
44
|
-
*/
|
|
45
|
-
clearPrevious(): Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
* Removes the first track from the queue.
|
|
48
|
-
*/
|
|
49
|
-
dequeue(): Promise<Track | undefined>;
|
|
50
|
-
/**
|
|
51
|
-
* Destroys the queue and releases all resources.
|
|
52
|
-
* After calling this method, the queue must not be used again.
|
|
53
|
-
*/
|
|
54
|
-
destroy(): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* @returns The total duration of the queue in milliseconds.
|
|
57
|
-
* This includes the duration of the currently playing track.
|
|
58
|
-
*/
|
|
59
|
-
duration(): Promise<number>;
|
|
60
|
-
/**
|
|
61
|
-
* Adds a track to the front of the queue.
|
|
62
|
-
* @param track The track or tracks to add.
|
|
63
|
-
*/
|
|
64
|
-
enqueueFront(track: Track | Track[]): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Whether all tracks in the queue match the specified condition.
|
|
67
|
-
* @param callback The condition to match.
|
|
68
|
-
* @returns Whether all tracks in the queue match the specified condition.
|
|
69
|
-
*/
|
|
70
|
-
everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
|
|
71
|
-
/**
|
|
72
|
-
* Filters the tracks in the queue.
|
|
73
|
-
* @param callback The condition to match.
|
|
74
|
-
* @returns The tracks that match the condition.
|
|
75
|
-
*/
|
|
76
|
-
filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
|
|
77
|
-
/**
|
|
78
|
-
* Finds the first track in the queue that matches the specified condition.
|
|
79
|
-
* @param callback The condition to match.
|
|
80
|
-
* @returns The first track that matches the condition.
|
|
81
|
-
*/
|
|
82
|
-
findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
|
|
83
|
-
/**
|
|
84
|
-
* @returns The current track.
|
|
85
|
-
*/
|
|
86
|
-
getCurrent(): Promise<Track | null>;
|
|
87
|
-
/**
|
|
88
|
-
* @returns The previous tracks.
|
|
89
|
-
*/
|
|
90
|
-
getPrevious(): Promise<Track[]>;
|
|
91
|
-
/**
|
|
92
|
-
* @returns The tracks in the queue from the start to the end.
|
|
93
|
-
*/
|
|
94
|
-
getSlice(start?: number, end?: number): Promise<Track[]>;
|
|
95
|
-
/**
|
|
96
|
-
* @returns The tracks in the queue.
|
|
97
|
-
*/
|
|
98
|
-
getTracks(): Promise<Track[]>;
|
|
99
|
-
/**
|
|
100
|
-
* Maps the tracks in the queue.
|
|
101
|
-
* @returns The tracks in the queue after the specified index.
|
|
102
|
-
*/
|
|
103
|
-
mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
|
|
104
|
-
/**
|
|
105
|
-
* Modifies the queue at the specified index.
|
|
106
|
-
* @param start The start index.
|
|
107
|
-
* @param deleteCount The number of tracks to delete.
|
|
108
|
-
* @param items The tracks to insert.
|
|
109
|
-
* @returns The removed tracks.
|
|
110
|
-
*/
|
|
111
|
-
modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise<Track[]>;
|
|
112
|
-
/**
|
|
113
|
-
* Removes the newest track.
|
|
114
|
-
* @returns The newest track.
|
|
115
|
-
*/
|
|
116
|
-
popPrevious(): Promise<Track | null>;
|
|
117
|
-
/**
|
|
118
|
-
* Removes the track at the specified index.
|
|
119
|
-
* @param position The position to remove the track at.
|
|
120
|
-
* @param end The end position to remove the track at.
|
|
121
|
-
*/
|
|
122
|
-
remove(position?: number): Promise<Track[]>;
|
|
123
|
-
remove(start: number, end: number): Promise<Track[]>;
|
|
124
|
-
/**
|
|
125
|
-
* Shuffles the queue round-robin style.
|
|
126
|
-
*/
|
|
127
|
-
roundRobinShuffle(): Promise<void>;
|
|
128
|
-
/**
|
|
129
|
-
* Sets the current track.
|
|
130
|
-
* @param track The track to set.
|
|
131
|
-
*/
|
|
132
|
-
setCurrent(track: Track | null): Promise<void>;
|
|
133
|
-
/**
|
|
134
|
-
* Sets the previous track(s).
|
|
135
|
-
* @param track The track to set.
|
|
136
|
-
*/
|
|
137
|
-
setPrevious(track: Track | Track[]): Promise<void>;
|
|
138
|
-
/**
|
|
139
|
-
* Shuffles the queue.
|
|
140
|
-
*/
|
|
141
|
-
shuffle(): Promise<void>;
|
|
142
|
-
/**
|
|
143
|
-
* @returns The size of the queue.
|
|
144
|
-
*/
|
|
145
|
-
size(): Promise<number>;
|
|
146
|
-
/**
|
|
147
|
-
* @returns Whether any tracks in the queue match the specified condition.
|
|
148
|
-
*/
|
|
149
|
-
someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
|
|
150
|
-
/**
|
|
151
|
-
* @returns The total size of tracks in the queue including the current track.
|
|
152
|
-
*/
|
|
153
|
-
totalSize(): Promise<number>;
|
|
154
|
-
/**
|
|
155
|
-
* Shuffles the queue, but keeps the tracks of the same user together.
|
|
156
|
-
*/
|
|
157
|
-
userBlockShuffle(): Promise<void>;
|
|
158
|
-
/**
|
|
159
|
-
* @returns The current key.
|
|
160
|
-
*/
|
|
161
|
-
private get currentKey();
|
|
162
|
-
/**
|
|
163
|
-
* Deserializes a track from a string.
|
|
164
|
-
*/
|
|
165
|
-
private deserialize;
|
|
166
|
-
/**
|
|
167
|
-
* @returns The previous key.
|
|
168
|
-
*/
|
|
169
|
-
private get previousKey();
|
|
170
|
-
/**
|
|
171
|
-
* @returns The queue key.
|
|
172
|
-
*/
|
|
173
|
-
private get queueKey();
|
|
174
|
-
/**
|
|
175
|
-
* Helper to serialize/deserialize Track
|
|
176
|
-
*/
|
|
177
|
-
private serialize;
|
|
178
|
-
}
|