magmastream 2.9.3-dev.15 → 2.9.3-dev.16
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 +0 -9
- package/dist/structures/Node.js +1 -3
- package/dist/structures/Player.js +0 -109
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2343,15 +2343,6 @@ declare class Player {
|
|
|
2343
2343
|
* @returns {Promise<Player>} - The player instance after being moved.
|
|
2344
2344
|
*/
|
|
2345
2345
|
moveNode(identifier: string): Promise<Player>;
|
|
2346
|
-
/**
|
|
2347
|
-
* Transfers the player to a new server. If the player already exists on the new server
|
|
2348
|
-
* and force is false, this method will return the existing player. Otherwise, a new player
|
|
2349
|
-
* will be created and the current player will be destroyed.
|
|
2350
|
-
* @param {PlayerOptions} newOptions - The new options for the player.
|
|
2351
|
-
* @param {boolean} force - Whether to force the creation of a new player.
|
|
2352
|
-
* @returns {Promise<Player>} - The new player instance.
|
|
2353
|
-
*/
|
|
2354
|
-
switchGuild(newOptions: PlayerOptions, force?: boolean): Promise<Player>;
|
|
2355
2346
|
/**
|
|
2356
2347
|
* Retrieves the data associated with the player.
|
|
2357
2348
|
* @returns {Record<string, unknown>} - The data associated with the player.
|
package/dist/structures/Node.js
CHANGED
|
@@ -356,9 +356,7 @@ class Node {
|
|
|
356
356
|
// Automove all players connected to that node
|
|
357
357
|
const players = this.manager.players.filter((p) => p.node == this);
|
|
358
358
|
if (players.size) {
|
|
359
|
-
|
|
360
|
-
await player.autoMoveNode();
|
|
361
|
-
}
|
|
359
|
+
await Promise.all(Array.from(players.values(), (player) => player.autoMoveNode()));
|
|
362
360
|
}
|
|
363
361
|
this.socket.close(1000, "destroy");
|
|
364
362
|
this.socket.removeAllListeners();
|
|
@@ -959,115 +959,6 @@ class Player {
|
|
|
959
959
|
console.error(error);
|
|
960
960
|
}
|
|
961
961
|
}
|
|
962
|
-
/**
|
|
963
|
-
* Transfers the player to a new server. If the player already exists on the new server
|
|
964
|
-
* and force is false, this method will return the existing player. Otherwise, a new player
|
|
965
|
-
* will be created and the current player will be destroyed.
|
|
966
|
-
* @param {PlayerOptions} newOptions - The new options for the player.
|
|
967
|
-
* @param {boolean} force - Whether to force the creation of a new player.
|
|
968
|
-
* @returns {Promise<Player>} - The new player instance.
|
|
969
|
-
*/
|
|
970
|
-
async switchGuild(newOptions, force = false) {
|
|
971
|
-
if (!newOptions.guildId) {
|
|
972
|
-
throw new MagmastreamError_1.MagmaStreamError({
|
|
973
|
-
code: Enums_1.MagmaStreamErrorCode.PLAYER_INVALID_CONFIG,
|
|
974
|
-
message: "guildId is required for switchGuild",
|
|
975
|
-
});
|
|
976
|
-
}
|
|
977
|
-
if (!newOptions.voiceChannelId) {
|
|
978
|
-
throw new MagmastreamError_1.MagmaStreamError({
|
|
979
|
-
code: Enums_1.MagmaStreamErrorCode.PLAYER_INVALID_CONFIG,
|
|
980
|
-
message: "voiceChannelId is required for switchGuild",
|
|
981
|
-
});
|
|
982
|
-
}
|
|
983
|
-
if (!newOptions.textChannelId) {
|
|
984
|
-
throw new MagmastreamError_1.MagmaStreamError({
|
|
985
|
-
code: Enums_1.MagmaStreamErrorCode.PLAYER_INVALID_CONFIG,
|
|
986
|
-
message: "textChannelId is required for switchGuild",
|
|
987
|
-
});
|
|
988
|
-
}
|
|
989
|
-
// Check if a player already exists for the new guild
|
|
990
|
-
let newPlayer = this.manager.getPlayer(newOptions.guildId);
|
|
991
|
-
// If the player already exists and force is false, return the existing player
|
|
992
|
-
if (newPlayer && !force)
|
|
993
|
-
return newPlayer;
|
|
994
|
-
const oldPlayerProperties = {
|
|
995
|
-
paused: this.paused,
|
|
996
|
-
selfMute: this.options.selfMute,
|
|
997
|
-
selfDeafen: this.options.selfDeafen,
|
|
998
|
-
volume: this.volume,
|
|
999
|
-
position: this.position,
|
|
1000
|
-
queue: {
|
|
1001
|
-
current: await this.queue.getCurrent(),
|
|
1002
|
-
tracks: [...(await this.queue.getTracks())],
|
|
1003
|
-
previous: [...(await this.queue.getPrevious())],
|
|
1004
|
-
},
|
|
1005
|
-
trackRepeat: this.trackRepeat,
|
|
1006
|
-
queueRepeat: this.queueRepeat,
|
|
1007
|
-
dynamicRepeat: this.dynamicRepeat,
|
|
1008
|
-
dynamicRepeatIntervalMs: this.dynamicRepeatIntervalMs,
|
|
1009
|
-
ClientUser: this.get("Internal_AutoplayUser"),
|
|
1010
|
-
filters: this.filters,
|
|
1011
|
-
nowPlayingMessage: this.nowPlayingMessage,
|
|
1012
|
-
isAutoplay: this.isAutoplay,
|
|
1013
|
-
applyVolumeAsFilter: this.options.applyVolumeAsFilter,
|
|
1014
|
-
pauseOnDisconnect: this.options.pauseOnDisconnect,
|
|
1015
|
-
};
|
|
1016
|
-
// If force is true, destroy the existing player for the new guild
|
|
1017
|
-
if (force && newPlayer) {
|
|
1018
|
-
await newPlayer.destroy();
|
|
1019
|
-
}
|
|
1020
|
-
newOptions.nodeIdentifier = newOptions.nodeIdentifier ?? this.options.nodeIdentifier;
|
|
1021
|
-
newOptions.selfDeafen = newOptions.selfDeafen ?? oldPlayerProperties.selfDeafen;
|
|
1022
|
-
newOptions.selfMute = newOptions.selfMute ?? oldPlayerProperties.selfMute;
|
|
1023
|
-
newOptions.volume = newOptions.volume ?? oldPlayerProperties.volume;
|
|
1024
|
-
newOptions.applyVolumeAsFilter = newOptions.applyVolumeAsFilter ?? oldPlayerProperties.applyVolumeAsFilter;
|
|
1025
|
-
newOptions.pauseOnDisconnect = newOptions.pauseOnDisconnect ?? oldPlayerProperties.pauseOnDisconnect;
|
|
1026
|
-
// Deep clone the current player
|
|
1027
|
-
const clonedPlayer = this.manager.create(newOptions);
|
|
1028
|
-
// Connect the cloned player to the new voice channel
|
|
1029
|
-
clonedPlayer.connect();
|
|
1030
|
-
// Update the player's state on the Lavalink node
|
|
1031
|
-
await clonedPlayer.node.rest.updatePlayer({
|
|
1032
|
-
guildId: clonedPlayer.guildId,
|
|
1033
|
-
data: {
|
|
1034
|
-
paused: oldPlayerProperties.paused,
|
|
1035
|
-
volume: oldPlayerProperties.volume,
|
|
1036
|
-
position: oldPlayerProperties.position,
|
|
1037
|
-
encodedTrack: oldPlayerProperties.queue.current?.track,
|
|
1038
|
-
},
|
|
1039
|
-
});
|
|
1040
|
-
await clonedPlayer.queue.setCurrent(oldPlayerProperties.queue.current);
|
|
1041
|
-
await clonedPlayer.queue.addPrevious(oldPlayerProperties.queue.previous);
|
|
1042
|
-
await clonedPlayer.queue.add(oldPlayerProperties.queue.tracks);
|
|
1043
|
-
clonedPlayer.filters = oldPlayerProperties.filters;
|
|
1044
|
-
clonedPlayer.isAutoplay = oldPlayerProperties.isAutoplay;
|
|
1045
|
-
clonedPlayer.nowPlayingMessage = oldPlayerProperties.nowPlayingMessage;
|
|
1046
|
-
clonedPlayer.trackRepeat = oldPlayerProperties.trackRepeat;
|
|
1047
|
-
clonedPlayer.queueRepeat = oldPlayerProperties.queueRepeat;
|
|
1048
|
-
clonedPlayer.dynamicRepeat = oldPlayerProperties.dynamicRepeat;
|
|
1049
|
-
clonedPlayer.dynamicRepeatIntervalMs = oldPlayerProperties.dynamicRepeatIntervalMs;
|
|
1050
|
-
clonedPlayer.set("Internal_AutoplayUser", oldPlayerProperties.ClientUser);
|
|
1051
|
-
clonedPlayer.paused = oldPlayerProperties.paused;
|
|
1052
|
-
// Update filters for the cloned player
|
|
1053
|
-
await clonedPlayer.filters.updateFilters();
|
|
1054
|
-
// Debug information
|
|
1055
|
-
const debugInfo = {
|
|
1056
|
-
success: true,
|
|
1057
|
-
message: `Transferred ${await clonedPlayer.queue.size()} tracks successfully to <#${newOptions.voiceChannelId}> bound to <#${newOptions.textChannelId}>.`,
|
|
1058
|
-
player: {
|
|
1059
|
-
guildId: clonedPlayer.guildId,
|
|
1060
|
-
voiceChannelId: clonedPlayer.voiceChannelId,
|
|
1061
|
-
textChannelId: clonedPlayer.textChannelId,
|
|
1062
|
-
volume: clonedPlayer.volume,
|
|
1063
|
-
playing: clonedPlayer.playing,
|
|
1064
|
-
queueSize: clonedPlayer.queue.size,
|
|
1065
|
-
},
|
|
1066
|
-
};
|
|
1067
|
-
this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[PLAYER] Transferred player to a new server: ${Utils_1.JSONUtils.safe(debugInfo, 2)}.`);
|
|
1068
|
-
// Return the cloned player
|
|
1069
|
-
return clonedPlayer;
|
|
1070
|
-
}
|
|
1071
962
|
/**
|
|
1072
963
|
* Retrieves the data associated with the player.
|
|
1073
964
|
* @returns {Record<string, unknown>} - The data associated with the player.
|