magmastream 2.9.0-dev.27 → 2.9.0-dev.29

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.
@@ -1,16 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ManagerEventTypes = exports.PlayerStateEventTypes = exports.AutoPlayPlatform = exports.SearchPlatform = exports.UseNodeOptions = exports.TrackPartial = exports.StateStorageType = exports.Manager = void 0;
3
+ exports.Manager = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const Utils_1 = require("./Utils");
6
6
  const collection_1 = require("@discordjs/collection");
7
7
  const events_1 = require("events");
8
+ const Node_1 = require("./Node");
8
9
  const __1 = require("..");
9
10
  const managerCheck_1 = tslib_1.__importDefault(require("../utils/managerCheck"));
10
11
  const blockedWords_1 = require("../config/blockedWords");
11
12
  const promises_1 = tslib_1.__importDefault(require("fs/promises"));
12
13
  const path_1 = tslib_1.__importDefault(require("path"));
13
14
  const ioredis_1 = tslib_1.__importDefault(require("ioredis"));
15
+ const Enums_1 = require("./Enums");
14
16
  /**
15
17
  * The main hub for interacting with Lavalink and using Magmastream,
16
18
  */
@@ -23,6 +25,7 @@ class Manager extends events_1.EventEmitter {
23
25
  options;
24
26
  initiated = false;
25
27
  redis;
28
+ _send;
26
29
  /**
27
30
  * Initiates the Manager class.
28
31
  * @param options
@@ -41,14 +44,20 @@ class Manager extends events_1.EventEmitter {
41
44
  constructor(options) {
42
45
  super();
43
46
  (0, managerCheck_1.default)(options);
47
+ // Initialize structures
44
48
  Utils_1.Structure.get("Player").init(this);
45
- Utils_1.Structure.get("Node").init(this);
46
49
  Utils_1.TrackUtils.init(this);
47
50
  Utils_1.AutoPlayUtils.init(this);
48
51
  if (options.trackPartial) {
49
52
  Utils_1.TrackUtils.setTrackPartial(options.trackPartial);
50
53
  delete options.trackPartial;
51
54
  }
55
+ if (options.clientId)
56
+ this.options.clientId = options.clientId;
57
+ if (options.clusterId)
58
+ this.options.clusterId = options.clusterId;
59
+ if (options.send && !this._send)
60
+ this._send = options.send;
52
61
  this.options = {
53
62
  enabledPlugins: [],
54
63
  nodes: [
@@ -62,15 +71,15 @@ class Manager extends events_1.EventEmitter {
62
71
  playNextOnEnd: true,
63
72
  enablePriorityMode: false,
64
73
  clientName: "Magmastream",
65
- defaultSearchPlatform: SearchPlatform.YouTube,
66
- useNode: UseNodeOptions.LeastPlayers,
74
+ defaultSearchPlatform: Enums_1.SearchPlatform.YouTube,
75
+ useNode: Enums_1.UseNodeOptions.LeastPlayers,
67
76
  maxPreviousTracks: options.maxPreviousTracks ?? 20,
68
- stateStorage: { type: StateStorageType.Collection },
77
+ stateStorage: { type: Enums_1.StateStorageType.Collection },
69
78
  ...options,
70
79
  };
71
80
  if (this.options.nodes) {
72
81
  for (const nodeOptions of this.options.nodes)
73
- new (Utils_1.Structure.get("Node"))(nodeOptions);
82
+ new Node_1.Node(this, nodeOptions);
74
83
  }
75
84
  process.on("SIGINT", async () => {
76
85
  console.warn("\x1b[33mSIGINT received! Graceful shutdown initiated...\x1b[0m");
@@ -102,29 +111,34 @@ class Manager extends events_1.EventEmitter {
102
111
  }
103
112
  /**
104
113
  * Initiates the Manager.
105
- * @param clientId - The Discord client ID (required).
114
+ * @param clientId - The Discord client ID (only required when not using any of the magmastream wrappers).
106
115
  * @param clusterId - The cluster ID which runs the current process (required).
107
116
  * @returns The manager instance.
108
117
  */
109
- init(clientId, clusterId = 0) {
118
+ init(options = {}) {
110
119
  if (this.initiated) {
111
120
  return this;
112
121
  }
113
- if (typeof clientId !== "string" || !/^\d+$/.test(clientId)) {
114
- throw new Error('"clientId" must be a valid Discord client ID.');
122
+ const { clientId, clusterId = 0 } = options;
123
+ if (clientId !== undefined) {
124
+ if (typeof clientId !== "string" || !/^\d+$/.test(clientId)) {
125
+ throw new Error('"clientId" must be a valid Discord client ID.');
126
+ }
127
+ this.options.clientId = clientId;
115
128
  }
116
- this.options.clientId = clientId;
117
129
  if (typeof clusterId !== "number") {
118
130
  console.warn('"clusterId" is not a valid number, defaulting to 0.');
119
- clusterId = 0;
131
+ this.options.clusterId = 0;
132
+ }
133
+ else {
134
+ this.options.clusterId = clusterId;
120
135
  }
121
- this.options.clusterId = clusterId;
122
136
  for (const node of this.nodes.values()) {
123
137
  try {
124
138
  node.connect();
125
139
  }
126
140
  catch (err) {
127
- this.emit(ManagerEventTypes.NodeError, node, err);
141
+ this.emit(Enums_1.ManagerEventTypes.NodeError, node, err);
128
142
  }
129
143
  }
130
144
  if (this.options.enabledPlugins) {
@@ -134,7 +148,7 @@ class Manager extends events_1.EventEmitter {
134
148
  plugin.load(this);
135
149
  }
136
150
  }
137
- if (this.options.stateStorage?.type === StateStorageType.Redis) {
151
+ if (this.options.stateStorage?.type === Enums_1.StateStorageType.Redis) {
138
152
  const config = this.options.stateStorage.redisConfig;
139
153
  this.redis = new ioredis_1.default({
140
154
  host: config.host,
@@ -159,7 +173,7 @@ class Manager extends events_1.EventEmitter {
159
173
  const _query = typeof query === "string" ? { query } : query;
160
174
  const _source = _query.source ?? this.options.defaultSearchPlatform;
161
175
  let search = /^https?:\/\//.test(_query.query) ? _query.query : `${_source}:${_query.query}`;
162
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Performing ${_source} search for: ${_query.query}`);
176
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Performing ${_source} search for: ${_query.query}`);
163
177
  try {
164
178
  const res = (await node.rest.get(`/v4/loadtracks?identifier=${encodeURIComponent(search)}`));
165
179
  if (!res)
@@ -167,13 +181,13 @@ class Manager extends events_1.EventEmitter {
167
181
  let tracks = [];
168
182
  let playlist = null;
169
183
  switch (res.loadType) {
170
- case Utils_1.LoadTypes.Search:
184
+ case Enums_1.LoadTypes.Search:
171
185
  tracks = res.data.map((track) => Utils_1.TrackUtils.build(track, requester));
172
186
  break;
173
- case Utils_1.LoadTypes.Track:
187
+ case Enums_1.LoadTypes.Track:
174
188
  tracks = [Utils_1.TrackUtils.build(res.data, requester)];
175
189
  break;
176
- case Utils_1.LoadTypes.Playlist: {
190
+ case Enums_1.LoadTypes.Playlist: {
177
191
  const playlistData = res.data;
178
192
  tracks = playlistData.tracks.map((track) => Utils_1.TrackUtils.build(track, requester));
179
193
  playlist = {
@@ -203,7 +217,7 @@ class Manager extends events_1.EventEmitter {
203
217
  }
204
218
  }
205
219
  const result = { loadType: res.loadType, tracks, playlist };
206
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Result ${_source} search for: ${_query.query}: ${JSON.stringify(result)}`);
220
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Result ${_source} search for: ${_query.query}: ${JSON.stringify(result)}`);
207
221
  return result;
208
222
  }
209
223
  catch (err) {
@@ -237,7 +251,7 @@ class Manager extends events_1.EventEmitter {
237
251
  return this.players.get(options.guildId);
238
252
  }
239
253
  // Create a new player with the given options
240
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Creating new player with options: ${JSON.stringify(options)}`);
254
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Creating new player with options: ${JSON.stringify(options)}`);
241
255
  return new (Utils_1.Structure.get("Player"))(options);
242
256
  }
243
257
  /**
@@ -246,7 +260,7 @@ class Manager extends events_1.EventEmitter {
246
260
  * @returns A promise that resolves when the player has been destroyed.
247
261
  */
248
262
  async destroy(guildId) {
249
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Destroying player: ${guildId}`);
263
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Destroying player: ${guildId}`);
250
264
  const player = this.getPlayer(guildId);
251
265
  if (!player)
252
266
  return;
@@ -259,15 +273,19 @@ class Manager extends events_1.EventEmitter {
259
273
  * @returns The created node.
260
274
  */
261
275
  createNode(options) {
276
+ const key = options.identifier || options.host;
262
277
  // Check if the node already exists in the manager's collection
263
- if (this.nodes.has(options.identifier || options.host)) {
278
+ if (this.nodes.has(key)) {
264
279
  // Return the existing node if it does
265
- return this.nodes.get(options.identifier || options.host);
280
+ return this.nodes.get(key);
266
281
  }
282
+ const node = new Node_1.Node(this, options);
283
+ // Set the node in the manager's collection
284
+ this.nodes.set(key, node);
267
285
  // Emit a debug event for node creation
268
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Creating new node with options: ${JSON.stringify(options)}`);
269
- // Create a new node with the given options
270
- return new (Utils_1.Structure.get("Node"))(options);
286
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Creating new node with options: ${JSON.stringify(options)}`);
287
+ // Return the created node
288
+ return node;
271
289
  }
272
290
  /**
273
291
  * Destroys a node if it exists. Emits a debug event if the node is found and destroyed.
@@ -277,11 +295,13 @@ class Manager extends events_1.EventEmitter {
277
295
  */
278
296
  async destroyNode(identifier) {
279
297
  const node = this.nodes.get(identifier);
280
- if (!node)
298
+ if (!node) {
299
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Tried to destroy non-existent node: ${identifier}`);
281
300
  return;
282
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Destroying node: ${identifier}`);
283
- await node.destroy();
301
+ }
302
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Destroying node: ${identifier}`);
284
303
  this.nodes.delete(identifier);
304
+ await node.destroy();
285
305
  }
286
306
  /**
287
307
  * Attaches an event listener to the manager.
@@ -307,7 +327,7 @@ class Manager extends events_1.EventEmitter {
307
327
  const player = this.getPlayer(update.guild_id);
308
328
  if (!player)
309
329
  return;
310
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Updating voice state: ${JSON.stringify(update)}`);
330
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Updating voice state: ${JSON.stringify(update)}`);
311
331
  if ("token" in update) {
312
332
  return await this.handleVoiceServerUpdate(player, update);
313
333
  }
@@ -323,7 +343,7 @@ class Manager extends events_1.EventEmitter {
323
343
  * @throws Will throw an error if no nodes are available or if the API request fails.
324
344
  */
325
345
  decodeTracks(tracks) {
326
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Decoding tracks: ${JSON.stringify(tracks)}`);
346
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Decoding tracks: ${JSON.stringify(tracks)}`);
327
347
  return new Promise(async (resolve, reject) => {
328
348
  const node = this.nodes.first();
329
349
  if (!node)
@@ -352,29 +372,29 @@ class Manager extends events_1.EventEmitter {
352
372
  */
353
373
  async savePlayerState(guildId) {
354
374
  switch (this.options.stateStorage.type) {
355
- case StateStorageType.Collection:
375
+ case Enums_1.StateStorageType.Collection:
356
376
  {
357
377
  try {
358
378
  const playerStateFilePath = await this.getPlayerFilePath(guildId);
359
379
  const player = this.getPlayer(guildId);
360
- if (!player || player.state === Utils_1.StateTypes.Disconnected || !player.voiceChannelId) {
380
+ if (!player || player.state === Enums_1.StateTypes.Disconnected || !player.voiceChannelId) {
361
381
  console.warn(`Skipping save for inactive player: ${guildId}`);
362
382
  return;
363
383
  }
364
384
  const serializedPlayer = this.serializePlayer(player);
365
385
  await promises_1.default.writeFile(playerStateFilePath, JSON.stringify(serializedPlayer, null, 2), "utf-8");
366
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Player state saved: ${guildId}`);
386
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Player state saved: ${guildId}`);
367
387
  }
368
388
  catch (error) {
369
389
  console.error(`Error saving player state for guild ${guildId}:`, error);
370
390
  }
371
391
  }
372
392
  break;
373
- case StateStorageType.Redis:
393
+ case Enums_1.StateStorageType.Redis:
374
394
  {
375
395
  try {
376
396
  const player = this.getPlayer(guildId);
377
- if (!player || player.state === Utils_1.StateTypes.Disconnected || !player.voiceChannelId) {
397
+ if (!player || player.state === Enums_1.StateTypes.Disconnected || !player.voiceChannelId) {
378
398
  console.warn(`Skipping save for inactive player: ${guildId}`);
379
399
  return;
380
400
  }
@@ -383,7 +403,7 @@ class Manager extends events_1.EventEmitter {
383
403
  ? this.options.stateStorage.redisConfig.prefix
384
404
  : this.options.stateStorage.redisConfig.prefix ?? "magmastream:"}playerstore:${guildId}`;
385
405
  await this.redis.set(redisKey, JSON.stringify(serializedPlayer));
386
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Player state saved to Redis: ${guildId}`);
406
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Player state saved to Redis: ${guildId}`);
387
407
  }
388
408
  catch (error) {
389
409
  console.error(`Error saving player state to Redis for guild ${guildId}:`, error);
@@ -408,20 +428,20 @@ class Manager extends events_1.EventEmitter {
408
428
  * @returns A promise that resolves when the player states have been loaded.
409
429
  */
410
430
  async loadPlayerStates(nodeId) {
411
- this.emit(ManagerEventTypes.Debug, "[MANAGER] Loading saved players.");
431
+ this.emit(Enums_1.ManagerEventTypes.Debug, "[MANAGER] Loading saved players.");
412
432
  const node = this.nodes.get(nodeId);
413
433
  if (!node)
414
434
  throw new Error(`Could not find node: ${nodeId}`);
415
435
  const info = (await node.rest.getAllPlayers());
416
436
  switch (this.options.stateStorage.type) {
417
- case StateStorageType.Collection:
437
+ case Enums_1.StateStorageType.Collection:
418
438
  {
419
439
  const playerStatesDir = path_1.default.join(process.cwd(), "magmastream", "dist", "sessionData", "players");
420
440
  try {
421
441
  // Check if the directory exists, and create it if it doesn't
422
442
  await promises_1.default.access(playerStatesDir).catch(async () => {
423
443
  await promises_1.default.mkdir(playerStatesDir, { recursive: true });
424
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Created directory: ${playerStatesDir}`);
444
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Created directory: ${playerStatesDir}`);
425
445
  });
426
446
  // Read the contents of the directory
427
447
  const playerFiles = await promises_1.default.readdir(playerStatesDir);
@@ -446,7 +466,7 @@ class Manager extends events_1.EventEmitter {
446
466
  volume: lavaPlayer.volume || state.options.volume,
447
467
  node: nodeId,
448
468
  };
449
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Recreating player: ${state.guildId} from saved file: ${JSON.stringify(state.options)}`);
469
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Recreating player: ${state.guildId} from saved file: ${JSON.stringify(state.options)}`);
450
470
  const player = this.create(playerOptions);
451
471
  await player.node.rest.updatePlayer({
452
472
  guildId: state.options.guildId,
@@ -466,7 +486,7 @@ class Manager extends events_1.EventEmitter {
466
486
  else {
467
487
  if (!currentTrack) {
468
488
  const payload = {
469
- reason: Utils_1.TrackEndReasonTypes.Finished,
489
+ reason: Enums_1.TrackEndReasonTypes.Finished,
470
490
  };
471
491
  await node.queueEnd(player, currentTrack, payload);
472
492
  }
@@ -478,7 +498,7 @@ class Manager extends events_1.EventEmitter {
478
498
  else {
479
499
  if (!currentTrack) {
480
500
  const payload = {
481
- reason: Utils_1.TrackEndReasonTypes.Finished,
501
+ reason: Enums_1.TrackEndReasonTypes.Finished,
482
502
  };
483
503
  await node.queueEnd(player, currentTrack, payload);
484
504
  }
@@ -551,12 +571,12 @@ class Manager extends events_1.EventEmitter {
551
571
  filterActions[filter](true);
552
572
  }
553
573
  }
554
- this.emit(ManagerEventTypes.PlayerRestored, player, node);
574
+ this.emit(Enums_1.ManagerEventTypes.PlayerRestored, player, node);
555
575
  await this.sleep(1000);
556
576
  }
557
577
  }
558
578
  catch (error) {
559
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Error processing file ${filePath}: ${error}`);
579
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Error processing file ${filePath}: ${error}`);
560
580
  continue; // Skip to the next file if there's an error
561
581
  }
562
582
  }
@@ -569,21 +589,21 @@ class Manager extends events_1.EventEmitter {
569
589
  const state = JSON.parse(data);
570
590
  if (state && typeof state === "object" && state.node.options.identifier === nodeId) {
571
591
  await promises_1.default.unlink(filePath); // Delete the file asynchronously
572
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Deleted player state file: ${filePath}`);
592
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Deleted player state file: ${filePath}`);
573
593
  }
574
594
  }
575
595
  catch (error) {
576
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Error deleting file ${filePath}: ${error}`);
596
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Error deleting file ${filePath}: ${error}`);
577
597
  continue; // Skip to the next file if there's an error
578
598
  }
579
599
  }
580
600
  }
581
601
  catch (error) {
582
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Error loading player states: ${error}`);
602
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Error loading player states: ${error}`);
583
603
  }
584
604
  }
585
605
  break;
586
- case StateStorageType.Redis:
606
+ case Enums_1.StateStorageType.Redis:
587
607
  {
588
608
  try {
589
609
  // Get all keys matching our pattern
@@ -615,7 +635,7 @@ class Manager extends events_1.EventEmitter {
615
635
  volume: lavaPlayer?.volume || state.options.volume,
616
636
  node: nodeId,
617
637
  };
618
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Recreating player: ${guildId} from Redis`);
638
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Recreating player: ${guildId} from Redis`);
619
639
  const player = this.create(playerOptions);
620
640
  await player.node.rest.updatePlayer({
621
641
  guildId: state.options.guildId,
@@ -636,7 +656,7 @@ class Manager extends events_1.EventEmitter {
636
656
  else {
637
657
  if (!currentTrack) {
638
658
  const payload = {
639
- reason: Utils_1.TrackEndReasonTypes.Finished,
659
+ reason: Enums_1.TrackEndReasonTypes.Finished,
640
660
  };
641
661
  await node.queueEnd(player, currentTrack, payload);
642
662
  }
@@ -648,7 +668,7 @@ class Manager extends events_1.EventEmitter {
648
668
  else {
649
669
  if (!currentTrack) {
650
670
  const payload = {
651
- reason: Utils_1.TrackEndReasonTypes.Finished,
671
+ reason: Enums_1.TrackEndReasonTypes.Finished,
652
672
  };
653
673
  await node.queueEnd(player, currentTrack, payload);
654
674
  }
@@ -723,27 +743,27 @@ class Manager extends events_1.EventEmitter {
723
743
  }
724
744
  // After processing, delete the Redis key
725
745
  await this.redis.del(key);
726
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Deleted player state from Redis: ${key}`);
727
- this.emit(ManagerEventTypes.PlayerRestored, player, node);
746
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Deleted player state from Redis: ${key}`);
747
+ this.emit(Enums_1.ManagerEventTypes.PlayerRestored, player, node);
728
748
  await this.sleep(1000);
729
749
  }
730
750
  }
731
751
  catch (error) {
732
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Error processing Redis key ${key}: ${error}`);
752
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Error processing Redis key ${key}: ${error}`);
733
753
  continue;
734
754
  }
735
755
  }
736
756
  }
737
757
  catch (error) {
738
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Error loading player states from Redis: ${error}`);
758
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Error loading player states from Redis: ${error}`);
739
759
  }
740
760
  }
741
761
  break;
742
762
  default:
743
763
  break;
744
764
  }
745
- this.emit(ManagerEventTypes.Debug, "[MANAGER] Finished loading saved players.");
746
- this.emit(ManagerEventTypes.RestoreComplete, node);
765
+ this.emit(Enums_1.ManagerEventTypes.Debug, "[MANAGER] Finished loading saved players.");
766
+ this.emit(Enums_1.ManagerEventTypes.RestoreComplete, node);
747
767
  }
748
768
  /**
749
769
  * Returns the node to use based on the configured `useNode` and `enablePriorityMode` options.
@@ -755,7 +775,7 @@ class Manager extends events_1.EventEmitter {
755
775
  get useableNode() {
756
776
  return this.options.enablePriorityMode
757
777
  ? this.priorityNode
758
- : this.options.useNode === UseNodeOptions.LeastLoad
778
+ : this.options.useNode === Enums_1.UseNodeOptions.LeastLoad
759
779
  ? this.leastLoadNode.first()
760
780
  : this.leastPlayersNode.first();
761
781
  }
@@ -915,13 +935,13 @@ class Manager extends events_1.EventEmitter {
915
935
  async handleVoiceStateUpdate(player, update) {
916
936
  if (update.channel_id) {
917
937
  if (player.voiceChannelId !== update.channel_id) {
918
- this.emit(ManagerEventTypes.PlayerMove, player, player.voiceChannelId, update.channel_id);
938
+ this.emit(Enums_1.ManagerEventTypes.PlayerMove, player, player.voiceChannelId, update.channel_id);
919
939
  }
920
940
  player.voiceState.sessionId = update.session_id;
921
941
  player.voiceChannelId = update.channel_id;
922
942
  return;
923
943
  }
924
- this.emit(ManagerEventTypes.PlayerDisconnect, player, player.voiceChannelId);
944
+ this.emit(Enums_1.ManagerEventTypes.PlayerDisconnect, player, player.voiceChannelId);
925
945
  player.voiceChannelId = null;
926
946
  player.voiceState = Object.assign({});
927
947
  await player.destroy();
@@ -1008,7 +1028,7 @@ class Manager extends events_1.EventEmitter {
1008
1028
  // Check if the directory exists, and create it if it doesn't
1009
1029
  await promises_1.default.access(playerStatesDir).catch(async () => {
1010
1030
  await promises_1.default.mkdir(playerStatesDir, { recursive: true });
1011
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Created directory: ${playerStatesDir}`);
1031
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Created directory: ${playerStatesDir}`);
1012
1032
  });
1013
1033
  // Get the list of player state files
1014
1034
  const playerFiles = await promises_1.default.readdir(playerStatesDir);
@@ -1022,12 +1042,12 @@ class Manager extends events_1.EventEmitter {
1022
1042
  if (!activeGuildIds.has(guildId)) {
1023
1043
  const filePath = path_1.default.join(playerStatesDir, file);
1024
1044
  await promises_1.default.unlink(filePath); // Delete the file asynchronously
1025
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Deleting inactive player: ${guildId}`);
1045
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Deleting inactive player: ${guildId}`);
1026
1046
  }
1027
1047
  }
1028
1048
  }
1029
1049
  catch (error) {
1030
- this.emit(ManagerEventTypes.Debug, `[MANAGER] Error cleaning up inactive players: ${error}`);
1050
+ this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Error cleaning up inactive players: ${error}`);
1031
1051
  }
1032
1052
  }
1033
1053
  /**
@@ -1088,116 +1108,13 @@ class Manager extends events_1.EventEmitter {
1088
1108
  }
1089
1109
  }
1090
1110
  // If no node has a cumulative weight greater than or equal to the random number, return the node with the lowest load
1091
- return this.options.useNode === UseNodeOptions.LeastLoad ? this.leastLoadNode.first() : this.leastPlayersNode.first();
1111
+ return this.options.useNode === Enums_1.UseNodeOptions.LeastLoad ? this.leastLoadNode.first() : this.leastPlayersNode.first();
1112
+ }
1113
+ send(packet) {
1114
+ return this._send(packet);
1115
+ }
1116
+ sendPacket(packet) {
1117
+ return this.send(packet);
1092
1118
  }
1093
1119
  }
1094
1120
  exports.Manager = Manager;
1095
- var StateStorageType;
1096
- (function (StateStorageType) {
1097
- StateStorageType["Collection"] = "collection";
1098
- StateStorageType["Redis"] = "redis";
1099
- })(StateStorageType || (exports.StateStorageType = StateStorageType = {}));
1100
- var TrackPartial;
1101
- (function (TrackPartial) {
1102
- /** The base64 encoded string of the track */
1103
- TrackPartial["Track"] = "track";
1104
- /** The title of the track */
1105
- TrackPartial["Title"] = "title";
1106
- /** The track identifier */
1107
- TrackPartial["Identifier"] = "identifier";
1108
- /** The author of the track */
1109
- TrackPartial["Author"] = "author";
1110
- /** The length of the track in milliseconds */
1111
- TrackPartial["Duration"] = "duration";
1112
- /** The ISRC of the track */
1113
- TrackPartial["Isrc"] = "isrc";
1114
- /** Whether the track is seekable */
1115
- TrackPartial["IsSeekable"] = "isSeekable";
1116
- /** Whether the track is a stream */
1117
- TrackPartial["IsStream"] = "isStream";
1118
- /** The URI of the track */
1119
- TrackPartial["Uri"] = "uri";
1120
- /** The artwork URL of the track */
1121
- TrackPartial["ArtworkUrl"] = "artworkUrl";
1122
- /** The source name of the track */
1123
- TrackPartial["SourceName"] = "sourceName";
1124
- /** The thumbnail of the track */
1125
- TrackPartial["ThumbNail"] = "thumbnail";
1126
- /** The requester of the track */
1127
- TrackPartial["Requester"] = "requester";
1128
- /** The plugin info of the track */
1129
- TrackPartial["PluginInfo"] = "pluginInfo";
1130
- /** The custom data of the track */
1131
- TrackPartial["CustomData"] = "customData";
1132
- })(TrackPartial || (exports.TrackPartial = TrackPartial = {}));
1133
- var UseNodeOptions;
1134
- (function (UseNodeOptions) {
1135
- UseNodeOptions["LeastLoad"] = "leastLoad";
1136
- UseNodeOptions["LeastPlayers"] = "leastPlayers";
1137
- })(UseNodeOptions || (exports.UseNodeOptions = UseNodeOptions = {}));
1138
- var SearchPlatform;
1139
- (function (SearchPlatform) {
1140
- SearchPlatform["AppleMusic"] = "amsearch";
1141
- SearchPlatform["Bandcamp"] = "bcsearch";
1142
- SearchPlatform["Deezer"] = "dzsearch";
1143
- SearchPlatform["Jiosaavn"] = "jssearch";
1144
- SearchPlatform["Qobuz"] = "qbsearch";
1145
- SearchPlatform["SoundCloud"] = "scsearch";
1146
- SearchPlatform["Spotify"] = "spsearch";
1147
- SearchPlatform["Tidal"] = "tdsearch";
1148
- SearchPlatform["VKMusic"] = "vksearch";
1149
- SearchPlatform["YouTube"] = "ytsearch";
1150
- SearchPlatform["YouTubeMusic"] = "ytmsearch";
1151
- })(SearchPlatform || (exports.SearchPlatform = SearchPlatform = {}));
1152
- var AutoPlayPlatform;
1153
- (function (AutoPlayPlatform) {
1154
- AutoPlayPlatform["Spotify"] = "spotify";
1155
- AutoPlayPlatform["Deezer"] = "deezer";
1156
- AutoPlayPlatform["SoundCloud"] = "soundcloud";
1157
- AutoPlayPlatform["Tidal"] = "tidal";
1158
- AutoPlayPlatform["VKMusic"] = "vkmusic";
1159
- AutoPlayPlatform["Qobuz"] = "qobuz";
1160
- AutoPlayPlatform["YouTube"] = "youtube";
1161
- })(AutoPlayPlatform || (exports.AutoPlayPlatform = AutoPlayPlatform = {}));
1162
- var PlayerStateEventTypes;
1163
- (function (PlayerStateEventTypes) {
1164
- PlayerStateEventTypes["AutoPlayChange"] = "playerAutoplay";
1165
- PlayerStateEventTypes["ConnectionChange"] = "playerConnection";
1166
- PlayerStateEventTypes["RepeatChange"] = "playerRepeat";
1167
- PlayerStateEventTypes["PauseChange"] = "playerPause";
1168
- PlayerStateEventTypes["QueueChange"] = "queueChange";
1169
- PlayerStateEventTypes["TrackChange"] = "trackChange";
1170
- PlayerStateEventTypes["VolumeChange"] = "volumeChange";
1171
- PlayerStateEventTypes["ChannelChange"] = "channelChange";
1172
- PlayerStateEventTypes["PlayerCreate"] = "playerCreate";
1173
- PlayerStateEventTypes["PlayerDestroy"] = "playerDestroy";
1174
- })(PlayerStateEventTypes || (exports.PlayerStateEventTypes = PlayerStateEventTypes = {}));
1175
- var ManagerEventTypes;
1176
- (function (ManagerEventTypes) {
1177
- ManagerEventTypes["ChapterStarted"] = "chapterStarted";
1178
- ManagerEventTypes["ChaptersLoaded"] = "chaptersLoaded";
1179
- ManagerEventTypes["Debug"] = "debug";
1180
- ManagerEventTypes["NodeConnect"] = "nodeConnect";
1181
- ManagerEventTypes["NodeCreate"] = "nodeCreate";
1182
- ManagerEventTypes["NodeDestroy"] = "nodeDestroy";
1183
- ManagerEventTypes["NodeDisconnect"] = "nodeDisconnect";
1184
- ManagerEventTypes["NodeError"] = "nodeError";
1185
- ManagerEventTypes["NodeRaw"] = "nodeRaw";
1186
- ManagerEventTypes["NodeReconnect"] = "nodeReconnect";
1187
- ManagerEventTypes["PlayerCreate"] = "playerCreate";
1188
- ManagerEventTypes["PlayerDestroy"] = "playerDestroy";
1189
- ManagerEventTypes["PlayerDisconnect"] = "playerDisconnect";
1190
- ManagerEventTypes["PlayerMove"] = "playerMove";
1191
- ManagerEventTypes["PlayerRestored"] = "playerRestored";
1192
- ManagerEventTypes["PlayerStateUpdate"] = "playerStateUpdate";
1193
- ManagerEventTypes["QueueEnd"] = "queueEnd";
1194
- ManagerEventTypes["RestoreComplete"] = "restoreComplete";
1195
- ManagerEventTypes["SegmentSkipped"] = "segmentSkipped";
1196
- ManagerEventTypes["SegmentsLoaded"] = "segmentsLoaded";
1197
- ManagerEventTypes["SocketClosed"] = "socketClosed";
1198
- ManagerEventTypes["TrackEnd"] = "trackEnd";
1199
- ManagerEventTypes["TrackError"] = "trackError";
1200
- ManagerEventTypes["TrackStart"] = "trackStart";
1201
- ManagerEventTypes["TrackStuck"] = "trackStuck";
1202
- })(ManagerEventTypes || (exports.ManagerEventTypes = ManagerEventTypes = {}));
1203
- // PlayerStore WILL BE REMOVED IF YOU DONT FIND A USE FOR IT.