magmastream 2.9.3-dev.15 → 2.9.3-dev.17

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 CHANGED
@@ -1497,6 +1497,7 @@ interface VoiceState {
1497
1497
  guildId: string;
1498
1498
  event: VoiceServer;
1499
1499
  sessionId?: string;
1500
+ channelId?: string;
1500
1501
  }
1501
1502
  /**
1502
1503
  * Voice State
@@ -1920,6 +1921,7 @@ interface RestPlayOptions {
1920
1921
  token: string;
1921
1922
  sessionId: string;
1922
1923
  endpoint: string;
1924
+ channelId: string;
1923
1925
  };
1924
1926
  /** Whether to not replace the track if a play payload is sent. */
1925
1927
  noReplace?: boolean;
@@ -2343,15 +2345,6 @@ declare class Player {
2343
2345
  * @returns {Promise<Player>} - The player instance after being moved.
2344
2346
  */
2345
2347
  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
2348
  /**
2356
2349
  * Retrieves the data associated with the player.
2357
2350
  * @returns {Record<string, unknown>} - The data associated with the player.
@@ -3147,8 +3140,6 @@ declare class Filters {
3147
3140
  distortion: DistortionOptions | null;
3148
3141
  equalizer: Band[];
3149
3142
  karaoke: KaraokeOptions | null;
3150
- manager: Manager;
3151
- player: Player;
3152
3143
  rotation: RotationOptions | null;
3153
3144
  timescale: TimescaleOptions | null;
3154
3145
  vibrato: VibratoOptions | null;
@@ -3156,6 +3147,8 @@ declare class Filters {
3156
3147
  volume: number;
3157
3148
  bassBoostlevel: number;
3158
3149
  filtersStatus: Record<AvailableFilters, boolean>;
3150
+ manager: Manager;
3151
+ player: Player;
3159
3152
  constructor(player: Player, manager: Manager);
3160
3153
  /**
3161
3154
  * Updates the player's audio filters.
@@ -8,8 +8,6 @@ class Filters {
8
8
  distortion;
9
9
  equalizer;
10
10
  karaoke;
11
- manager;
12
- player;
13
11
  rotation;
14
12
  timescale;
15
13
  vibrato;
@@ -17,15 +15,16 @@ class Filters {
17
15
  volume;
18
16
  bassBoostlevel;
19
17
  filtersStatus;
18
+ manager;
19
+ player;
20
20
  constructor(player, manager) {
21
21
  this.distortion = null;
22
22
  this.equalizer = [];
23
23
  this.karaoke = null;
24
- this.manager = manager;
25
- this.player = player;
26
24
  this.rotation = null;
27
25
  this.timescale = null;
28
26
  this.vibrato = null;
27
+ this.reverb = null;
29
28
  this.volume = 1.0;
30
29
  this.bassBoostlevel = 0;
31
30
  // Initialize filter status
@@ -33,6 +32,8 @@ class Filters {
33
32
  acc[filter] = false;
34
33
  return acc;
35
34
  }, {});
35
+ this.manager = manager;
36
+ this.player = player;
36
37
  }
37
38
  /**
38
39
  * Updates the player's audio filters.
@@ -563,6 +563,7 @@ class Manager extends events_1.EventEmitter {
563
563
  token: state.voiceState.event.token,
564
564
  endpoint: state.voiceState.event.endpoint,
565
565
  sessionId: state.voiceState.sessionId,
566
+ channelId: state.voiceState.event.channel_id,
566
567
  },
567
568
  },
568
569
  });
@@ -758,7 +759,14 @@ class Manager extends events_1.EventEmitter {
758
759
  const player = this.create(playerOptions);
759
760
  await player.node.rest.updatePlayer({
760
761
  guildId: state.options.guildId,
761
- data: { voice: { token: state.voiceState.event.token, endpoint: state.voiceState.event.endpoint, sessionId: state.voiceState.sessionId } },
762
+ data: {
763
+ voice: {
764
+ token: state.voiceState.event.token,
765
+ endpoint: state.voiceState.event.endpoint,
766
+ sessionId: state.voiceState.sessionId,
767
+ channelId: state.voiceState.event.channel_id,
768
+ },
769
+ },
762
770
  });
763
771
  player.connect();
764
772
  // Rest of the player state restoration code (tracks, filters, etc.)
@@ -1080,13 +1088,17 @@ class Manager extends events_1.EventEmitter {
1080
1088
  */
1081
1089
  async handleVoiceServerUpdate(player, update) {
1082
1090
  player.voiceState.event = update;
1083
- const { sessionId, event: { token, endpoint }, } = player.voiceState;
1091
+ const sessionId = player.voiceState.sessionId;
1092
+ const channelId = player.voiceState.channelId;
1093
+ const token = update.token;
1094
+ const endpoint = update.endpoint;
1095
+ this.emit(Enums_1.ManagerEventTypes.Debug, `Updated voice server for player ${player.guildId} with token ${token} | endpoint ${endpoint} | sessionId ${sessionId} | channelId ${channelId}`);
1096
+ if (!sessionId || !channelId)
1097
+ return;
1084
1098
  await player.node.rest.updatePlayer({
1085
1099
  guildId: player.guildId,
1086
- data: { voice: { token, endpoint, sessionId } },
1100
+ data: { voice: { token, endpoint, sessionId, channelId } },
1087
1101
  });
1088
- this.emit(Enums_1.ManagerEventTypes.Debug, `Updated voice server for player ${player.guildId} with token ${token} and endpoint ${endpoint} and sessionId ${sessionId}`);
1089
- return;
1090
1102
  }
1091
1103
  /**
1092
1104
  * Handles a voice state update by updating the player's voice channel and session ID if provided, or by disconnecting and destroying the player if the channel ID is null.
@@ -1097,23 +1109,30 @@ class Manager extends events_1.EventEmitter {
1097
1109
  */
1098
1110
  async handleVoiceStateUpdate(player, update) {
1099
1111
  this.emit(Enums_1.ManagerEventTypes.Debug, `Updated voice state for player ${player.guildId} with channel id ${update.channel_id} and session id ${update.session_id}`);
1100
- if (update.channel_id) {
1101
- if (player.voiceChannelId !== update.channel_id) {
1102
- this.emit(Enums_1.ManagerEventTypes.PlayerMove, player, player.voiceChannelId, update.channel_id);
1103
- }
1104
- player.voiceState.sessionId = update.session_id;
1105
- player.voiceChannelId = update.channel_id;
1106
- player.options.voiceChannelId = update.channel_id;
1112
+ if (!update.channel_id) {
1113
+ this.emit(Enums_1.ManagerEventTypes.PlayerDisconnect, player, player.voiceChannelId);
1114
+ player.voiceChannelId = null;
1115
+ player.state = Enums_1.StateTypes.Disconnected;
1116
+ player.voiceState = Object.assign({});
1117
+ if (player.options.pauseOnDisconnect)
1118
+ await player.pause(true);
1107
1119
  return;
1108
1120
  }
1109
- this.emit(Enums_1.ManagerEventTypes.PlayerDisconnect, player, player.voiceChannelId);
1110
- player.voiceChannelId = null;
1111
- player.state = Enums_1.StateTypes.Disconnected;
1112
- player.voiceState = Object.assign({});
1113
- if (player.options.pauseOnDisconnect) {
1114
- await player.pause(true);
1121
+ if (player.voiceChannelId !== update.channel_id) {
1122
+ this.emit(Enums_1.ManagerEventTypes.PlayerMove, player, player.voiceChannelId, update.channel_id);
1115
1123
  }
1116
- return;
1124
+ player.voiceState.sessionId = update.session_id;
1125
+ player.voiceState.channelId = update.channel_id;
1126
+ player.voiceChannelId = update.channel_id;
1127
+ player.options.voiceChannelId = update.channel_id;
1128
+ const token = player.voiceState.event?.token;
1129
+ const endpoint = player.voiceState.event?.endpoint;
1130
+ if (!token || !endpoint)
1131
+ return;
1132
+ await player.node.rest.updatePlayer({
1133
+ guildId: player.guildId,
1134
+ data: { voice: { token, endpoint, sessionId: update.session_id, channelId: update.channel_id } },
1135
+ });
1117
1136
  }
1118
1137
  /**
1119
1138
  * Cleans up inactive players by removing their state files from the file system.
@@ -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
- for (const player of players.values()) {
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();
@@ -928,7 +928,8 @@ class Player {
928
928
  const sessionId = this.voiceState?.sessionId;
929
929
  const token = this.voiceState?.event?.token;
930
930
  const endpoint = this.voiceState?.event?.endpoint;
931
- if (!sessionId || !token || !endpoint) {
931
+ const channelId = this.voiceState?.channelId;
932
+ if (!sessionId || !token || !endpoint || !channelId) {
932
933
  this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Voice state is not properly initialized for player ${this.guildId}. The bot might not be connected to a voice channel.`);
933
934
  throw new MagmastreamError_1.MagmaStreamError({
934
935
  code: Enums_1.MagmaStreamErrorCode.PLAYER_STATE_INVALID,
@@ -942,7 +943,7 @@ class Player {
942
943
  this.manager.players.set(this.guildId, this);
943
944
  await this.node.rest.updatePlayer({
944
945
  guildId: this.guildId,
945
- data: { paused: this.paused, volume: this.volume, position: playerPosition, encodedTrack: currentTrack?.track, voice: { token, endpoint, sessionId } },
946
+ data: { paused: this.paused, volume: this.volume, position: playerPosition, encodedTrack: currentTrack?.track, voice: { token, endpoint, sessionId, channelId } },
946
947
  });
947
948
  await this.filters.updateFilters();
948
949
  }
@@ -959,115 +960,6 @@ class Player {
959
960
  console.error(error);
960
961
  }
961
962
  }
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
963
  /**
1072
964
  * Retrieves the data associated with the player.
1073
965
  * @returns {Record<string, unknown>} - The data associated with the player.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magmastream",
3
- "version": "2.9.3-dev.15",
3
+ "version": "2.9.3-dev.17",
4
4
  "description": "A user-friendly Lavalink client designed for NodeJS.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,35 +20,38 @@
20
20
  "devDependencies": {
21
21
  "@favware/rollup-type-bundler": "^4.0.0",
22
22
  "@types/jsdom": "^27.0.0",
23
- "@types/lodash": "^4.17.23",
24
- "@types/node": "^25.0.9",
23
+ "@types/lodash": "^4.17.24",
24
+ "@types/node": "^25.3.0",
25
25
  "@types/ws": "^8.18.1",
26
- "@typescript-eslint/eslint-plugin": "^8.53.0",
27
- "@typescript-eslint/parser": "^8.53.0",
28
- "eslint": "^9.39.2",
26
+ "@typescript-eslint/eslint-plugin": "^8.56.0",
27
+ "@typescript-eslint/parser": "^8.56.0",
28
+ "eslint": "^10.0.1",
29
29
  "npm-run-all": "^4.1.5",
30
- "prettier": "^3.8.0",
31
- "typedoc": "^0.28.16",
30
+ "prettier": "^3.8.1",
31
+ "typedoc": "^0.28.17",
32
32
  "typedoc-plugin-no-inherit": "^1.6.1",
33
33
  "typescript": "^5.9.3"
34
34
  },
35
35
  "dependencies": {
36
36
  "@discordjs/collection": "^2.1.1",
37
- "axios": "^1.13.2",
37
+ "axios": "^1.13.5",
38
38
  "events": "^3.3.0",
39
- "ioredis": "^5.9.2",
40
- "jsdom": "^27.4.0",
41
- "lodash": "^4.17.21",
39
+ "ioredis": "^5.9.3",
40
+ "jsdom": "^28.1.0",
41
+ "lodash": "^4.17.23",
42
42
  "safe-stable-stringify": "^2.5.0",
43
43
  "tslib": "^2.8.1",
44
44
  "ws": "^8.19.0"
45
45
  },
46
46
  "optionalDependencies": {
47
- "discordeno": "21.x",
48
47
  "discord.js": "14.x",
48
+ "discordeno": "21.x",
49
49
  "eris": "0.18.x",
50
50
  "oceanic.js": "^1.13.0",
51
- "seyfert": "4.0.x"
51
+ "seyfert": "4.x"
52
+ },
53
+ "overrides": {
54
+ "undici": "^6.23.0"
52
55
  },
53
56
  "engines": {
54
57
  "node": ">=20.19.0"