magmastream 2.9.0-dev.24 → 2.9.0-dev.26

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.
@@ -246,11 +246,11 @@ class Manager extends events_1.EventEmitter {
246
246
  * @returns A promise that resolves when the player has been destroyed.
247
247
  */
248
248
  async destroy(guildId) {
249
- // Emit debug message for player destruction
250
249
  this.emit(ManagerEventTypes.Debug, `[MANAGER] Destroying player: ${guildId}`);
251
- // Remove the player from the manager's collection
252
- this.players.delete(guildId);
253
- // Clean up any inactive players
250
+ const player = this.getPlayer(guildId);
251
+ if (!player)
252
+ return;
253
+ await player.destroy();
254
254
  await this.cleanupInactivePlayers();
255
255
  }
256
256
  /**
@@ -313,13 +313,6 @@ class Manager extends events_1.EventEmitter {
313
313
  }
314
314
  if (update.user_id !== this.options.clientId)
315
315
  return;
316
- const missingSessionButHasEvent = !player.voiceState.sessionId && player.voiceState.event;
317
- if (missingSessionButHasEvent) {
318
- if (player.state !== Utils_1.StateTypes.Destroying && player.state !== Utils_1.StateTypes.Disconnected) {
319
- await player.destroy();
320
- }
321
- return;
322
- }
323
316
  return await this.handleVoiceStateUpdate(player, update);
324
317
  }
325
318
  /**
@@ -225,10 +225,6 @@ class Player {
225
225
  */
226
226
  async destroy(disconnect = true) {
227
227
  const oldPlayer = this ? { ...this } : null;
228
- if (this.state === Utils_1.StateTypes.Destroying || this.state === Utils_1.StateTypes.Disconnected) {
229
- console.debug(`[Player#destroy] Already destroying/destroyed for ${this.guildId}`);
230
- return false;
231
- }
232
228
  this.state = Utils_1.StateTypes.Destroying;
233
229
  if (disconnect) {
234
230
  await this.disconnect().catch((err) => {
@@ -803,8 +799,14 @@ class Player {
803
799
  }
804
800
  try {
805
801
  const playerPosition = this.position;
806
- const { sessionId, event: { token, endpoint }, } = this.voiceState;
807
802
  const currentTrack = (await this.queue.getCurrent()) ? await this.queue.getCurrent() : null;
803
+ // Safely get voice state properties with null checks
804
+ const sessionId = this.voiceState?.sessionId;
805
+ const token = this.voiceState?.event?.token;
806
+ const endpoint = this.voiceState?.event?.endpoint;
807
+ if (!sessionId || !token || !endpoint) {
808
+ throw new Error(`Voice state is not properly initialized for player ${this.guildId}. The bot might not be connected to a voice channel.`);
809
+ }
808
810
  await this.node.rest.destroyPlayer(this.guildId).catch(() => { });
809
811
  this.manager.players.delete(this.guildId);
810
812
  this.node = node;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magmastream",
3
- "version": "2.9.0-dev.24",
3
+ "version": "2.9.0-dev.26",
4
4
  "description": "A user-friendly Lavalink client designed for NodeJS.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",