magmastream 2.8.6-dev.1 → 2.8.6-dev.3
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 +3 -3
- package/dist/structures/Manager.js +9 -3
- package/dist/structures/Player.js +6 -21
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -932,7 +932,7 @@ declare class Manager extends EventEmitter {
|
|
|
932
932
|
* @param requester
|
|
933
933
|
* @returns The search result.
|
|
934
934
|
*/
|
|
935
|
-
search<T
|
|
935
|
+
search<T = unknown>(query: string | SearchQuery, requester?: T): Promise<SearchResult>;
|
|
936
936
|
/**
|
|
937
937
|
* Creates a player or returns one if it already exists.
|
|
938
938
|
* @param options The options to create the player with.
|
|
@@ -1445,7 +1445,7 @@ declare class Player {
|
|
|
1445
1445
|
* @param query
|
|
1446
1446
|
* @param requester
|
|
1447
1447
|
*/
|
|
1448
|
-
search<T
|
|
1448
|
+
search<T = unknown>(query: string | SearchQuery, requester?: T): Promise<SearchResult>;
|
|
1449
1449
|
/**
|
|
1450
1450
|
* Connects the player to the voice channel.
|
|
1451
1451
|
* @throws {RangeError} If no voice channel has been set.
|
|
@@ -1518,7 +1518,7 @@ declare class Player {
|
|
|
1518
1518
|
* recommended track if the first one doesn't work.
|
|
1519
1519
|
* @returns {this} - The player instance.
|
|
1520
1520
|
*/
|
|
1521
|
-
setAutoplay(autoplayState: boolean, botUser?:
|
|
1521
|
+
setAutoplay<T = unknown>(autoplayState: boolean, botUser?: T, tries?: number): this;
|
|
1522
1522
|
/**
|
|
1523
1523
|
* Gets recommended tracks and returns an array of tracks.
|
|
1524
1524
|
* @param {Track} track - The track to find recommendations for.
|
|
@@ -167,7 +167,7 @@ class Manager extends events_1.EventEmitter {
|
|
|
167
167
|
playlist = {
|
|
168
168
|
name: playlistData.info.name,
|
|
169
169
|
playlistInfo: playlistData.pluginInfo,
|
|
170
|
-
requester,
|
|
170
|
+
requester: requester,
|
|
171
171
|
tracks,
|
|
172
172
|
duration: tracks.reduce((acc, cur) => acc + (cur.duration || 0), 0),
|
|
173
173
|
};
|
|
@@ -455,8 +455,9 @@ class Manager extends events_1.EventEmitter {
|
|
|
455
455
|
if (state.dynamicRepeat) {
|
|
456
456
|
player.setDynamicRepeat(state.dynamicRepeat, state.dynamicLoopInterval._idleTimeout);
|
|
457
457
|
}
|
|
458
|
-
if (state.isAutoplay
|
|
459
|
-
|
|
458
|
+
if (state.isAutoplay) {
|
|
459
|
+
Object.setPrototypeOf(state.data.clientUser, { constructor: { name: "User" } });
|
|
460
|
+
player.setAutoplay(true, state.data.clientUser, state.autoplayTries);
|
|
460
461
|
}
|
|
461
462
|
if (state.data) {
|
|
462
463
|
for (const [name, value] of Object.entries(state.data)) {
|
|
@@ -770,6 +771,11 @@ class Manager extends events_1.EventEmitter {
|
|
|
770
771
|
previous: [...value.previous],
|
|
771
772
|
};
|
|
772
773
|
}
|
|
774
|
+
if (key === "data") {
|
|
775
|
+
return {
|
|
776
|
+
clientUser: value.Internal_BotUser ?? null,
|
|
777
|
+
};
|
|
778
|
+
}
|
|
773
779
|
return serialize(value);
|
|
774
780
|
}));
|
|
775
781
|
}
|
|
@@ -340,14 +340,14 @@ class Player {
|
|
|
340
340
|
*/
|
|
341
341
|
setAutoplay(autoplayState, botUser, tries) {
|
|
342
342
|
if (typeof autoplayState !== "boolean") {
|
|
343
|
-
throw new
|
|
343
|
+
throw new Error("autoplayState must be a boolean.");
|
|
344
344
|
}
|
|
345
345
|
if (autoplayState) {
|
|
346
346
|
if (!botUser) {
|
|
347
|
-
throw new
|
|
347
|
+
throw new Error("botUser must be provided when enabling autoplay.");
|
|
348
348
|
}
|
|
349
349
|
if (!["ClientUser", "User"].includes(botUser.constructor.name)) {
|
|
350
|
-
throw new
|
|
350
|
+
throw new Error("botUser must be a user-object.");
|
|
351
351
|
}
|
|
352
352
|
this.autoplayTries = tries && typeof tries === "number" && tries > 0 ? tries : 3; // Default to 3 if invalid
|
|
353
353
|
this.isAutoplay = true;
|
|
@@ -708,35 +708,20 @@ class Player {
|
|
|
708
708
|
* @throws {RangeError} If the amount is greater than the queue length.
|
|
709
709
|
*/
|
|
710
710
|
async stop(amount) {
|
|
711
|
-
const oldPlayer =
|
|
711
|
+
const oldPlayer = { ...this };
|
|
712
712
|
let removedTracks = [];
|
|
713
|
-
// If an amount is provided, remove that many tracks from the queue.
|
|
714
713
|
if (typeof amount === "number" && amount > 1) {
|
|
715
|
-
if (amount > this.queue.length)
|
|
714
|
+
if (amount > this.queue.length)
|
|
716
715
|
throw new RangeError("Cannot skip more than the queue length.");
|
|
717
|
-
}
|
|
718
716
|
removedTracks = this.queue.slice(0, amount - 1);
|
|
719
717
|
this.queue.splice(0, amount - 1);
|
|
720
718
|
}
|
|
721
|
-
|
|
722
|
-
// If no amount is provided, remove the current track if it exists.
|
|
723
|
-
if (this.queue.current) {
|
|
724
|
-
removedTracks.push(this.queue.current);
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
// Stop the player and send an event to the manager.
|
|
728
|
-
await this.node.rest.updatePlayer({
|
|
719
|
+
this.node.rest.updatePlayer({
|
|
729
720
|
guildId: this.guildId,
|
|
730
721
|
data: {
|
|
731
722
|
encodedTrack: null,
|
|
732
723
|
},
|
|
733
724
|
});
|
|
734
|
-
if (this.queue.length) {
|
|
735
|
-
this.queue.current = this.queue.shift();
|
|
736
|
-
// If autoplay is enabled, play the next track
|
|
737
|
-
if (this.manager.options.autoPlay)
|
|
738
|
-
await this.play();
|
|
739
|
-
}
|
|
740
725
|
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, {
|
|
741
726
|
changeType: Manager_1.PlayerStateEventTypes.QueueChange,
|
|
742
727
|
details: {
|