magmastream 2.9.3-dev.2 → 2.9.3-dev.20

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
@@ -3,12 +3,11 @@ import { GatewayVoiceStateUpdate } from 'discord-api-types/v10';
3
3
  import { EventEmitter } from 'events';
4
4
  import { User, ClientUser, Message, Client } from 'discord.js';
5
5
  import { User as User$1, Message as Message$1, Client as Client$2 } from 'oceanic.js';
6
- import { User as User$2, Message as Message$2 } from 'detritus-client/lib/structures';
6
+ import { User as User$2, Message as Message$2, Bot } from '@discordeno/bot';
7
7
  import { User as User$3, Message as Message$3, Client as Client$1 } from 'eris';
8
8
  import { User as User$4, ClientUser as ClientUser$1, Message as Message$4, Client as Client$3, WorkerClient } from 'seyfert';
9
9
  import WebSocket$1, { WebSocket } from 'ws';
10
10
  import { Redis } from 'ioredis';
11
- import { ClusterClient, ShardClient } from 'detritus-client';
12
11
 
13
12
  /** Represents an equalizer band. */
14
13
  interface Band {
@@ -170,7 +169,9 @@ declare enum TrackPartial {
170
169
  /** The plugin info of the track */
171
170
  PluginInfo = "pluginInfo",
172
171
  /** The custom data of the track */
173
- CustomData = "customData"
172
+ CustomData = "customData",
173
+ /** Whether the track got autoplayed */
174
+ IsAutoPlay = "isAutoplay"
174
175
  }
175
176
  /**
176
177
  * Manager Event Types Enum
@@ -284,6 +285,7 @@ declare enum MagmaStreamErrorCode {
284
285
  GENERAL_UNKNOWN = "MS_GENERAL_UNKNOWN",
285
286
  GENERAL_TIMEOUT = "MS_GENERAL_TIMEOUT",
286
287
  GENERAL_INVALID_MANAGER = "MS_GENERAL_INVALID_MANAGER",
288
+ INTENT_MISSING = "MS_INTENT_MISSING",
287
289
  MANAGER_INIT_FAILED = "MS_MANAGER_INIT_FAILED",
288
290
  MANAGER_INVALID_CONFIG = "MS_MANAGER_INVALID_CONFIG",
289
291
  MANAGER_SHUTDOWN_FAILED = "MS_MANAGER_SHUTDOWN_FAILED",
@@ -320,6 +322,7 @@ declare enum MagmaStreamErrorCode {
320
322
  UTILS_TRACK_PARTIAL_INVALID = "MS_UTILS_TRACK_PARTIAL_INVALID",
321
323
  UTILS_TRACK_BUILD_FAILED = "MS_UTILS_TRACK_BUILD_FAILED",
322
324
  UTILS_AUTOPLAY_BUILD_FAILED = "MS_UTILS_AUTOPLAY_BUILD_FAILED",
325
+ UTILS_PLAYER_SERIALIZE_FAILED = "MS_UTILS_PLAYER_SERIALIZE_FAILED",
323
326
  PLUGIN_LOAD_FAILED = "MS_PLUGIN_LOAD_FAILED",
324
327
  PLUGIN_RUNTIME_ERROR = "MS_PLUGIN_RUNTIME_ERROR"
325
328
  }
@@ -335,6 +338,10 @@ declare class JsonQueue implements IQueue {
335
338
  * The base path for the queue files.
336
339
  */
337
340
  private basePath;
341
+ /**
342
+ * Whether the queue has been destroyed.
343
+ */
344
+ private destroyed;
338
345
  /**
339
346
  * @param guildId The guild ID.
340
347
  * @param manager The manager.
@@ -361,6 +368,11 @@ declare class JsonQueue implements IQueue {
361
368
  * Removes the first track from the queue.
362
369
  */
363
370
  dequeue(): Promise<Track | undefined>;
371
+ /**
372
+ * Destroys the queue and releases all resources.
373
+ * After calling this method, the queue must not be used again.
374
+ */
375
+ destroy(): Promise<void>;
364
376
  /**
365
377
  * @returns The total duration of the queue.
366
378
  */
@@ -500,6 +512,10 @@ declare class MemoryQueue extends Array<Track> implements IQueue {
500
512
  manager: Manager;
501
513
  /** The guild ID property. */
502
514
  guildId: string;
515
+ /**
516
+ * Whether the queue has been destroyed.
517
+ */
518
+ private destroyed;
503
519
  /**
504
520
  * Constructs a new Queue.
505
521
  * @param guildId The guild ID.
@@ -511,67 +527,72 @@ declare class MemoryQueue extends Array<Track> implements IQueue {
511
527
  * @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
512
528
  * @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
513
529
  */
514
- add(track: Track | Track[], offset?: number): Promise<void>;
530
+ add(track: Track | Track[], offset?: number): void;
515
531
  /**
516
532
  * Adds a track to the previous tracks.
517
533
  * @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
518
534
  */
519
- addPrevious(track: Track | Track[]): Promise<void>;
535
+ addPrevious(track: Track | Track[]): void;
520
536
  /**
521
537
  * Clears the queue.
522
538
  * This will remove all tracks from the queue and emit a state update event.
523
539
  */
524
- clear(): Promise<void>;
540
+ clear(): void;
525
541
  /**
526
542
  * Clears the previous tracks.
527
543
  */
528
- clearPrevious(): Promise<void>;
544
+ clearPrevious(): void;
529
545
  /**
530
546
  * Removes the first element from the queue.
531
547
  */
532
- dequeue(): Promise<Track | undefined>;
548
+ dequeue(): Track | undefined;
549
+ /**
550
+ * Destroys the queue and releases all resources.
551
+ * After calling this method, the queue must not be used again.
552
+ */
553
+ destroy(): void;
533
554
  /**
534
555
  * The total duration of the queue in milliseconds.
535
556
  * This includes the duration of the currently playing track.
536
557
  */
537
- duration(): Promise<number>;
558
+ duration(): number;
538
559
  /**
539
560
  * Adds the specified track or tracks to the front of the queue.
540
561
  * @param track The track or tracks to add.
541
562
  */
542
- enqueueFront(track: Track | Track[]): Promise<void>;
563
+ enqueueFront(track: Track | Track[]): void;
543
564
  /**
544
565
  * @returns Whether all elements in the queue satisfy the provided testing function.
545
566
  */
546
- everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
567
+ everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): boolean;
547
568
  /**
548
569
  * @returns A new array with all elements that pass the test implemented by the provided function.
549
570
  */
550
- filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
571
+ filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Track[];
551
572
  /**
552
573
  * @returns The first element in the queue that satisfies the provided testing function.
553
574
  */
554
- findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
575
+ findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Track | undefined;
555
576
  /**
556
577
  * @returns The current track.
557
578
  */
558
- getCurrent(): Promise<Track | null>;
579
+ getCurrent(): Track | null;
559
580
  /**
560
581
  * @returns The previous tracks.
561
582
  */
562
- getPrevious(): Promise<Track[]>;
583
+ getPrevious(): Track[];
563
584
  /**
564
585
  * @returns The tracks in the queue from start to end.
565
586
  */
566
- getSlice(start?: number, end?: number): Promise<Track[]>;
587
+ getSlice(start?: number, end?: number): Track[];
567
588
  /**
568
589
  * @returns The tracks in the queue.
569
590
  */
570
- getTracks(): Promise<Track[]>;
591
+ getTracks(): Track[];
571
592
  /**
572
593
  * @returns A new array with the results of calling a provided function on every element in the queue.
573
594
  */
574
- mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
595
+ mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): T[];
575
596
  /**
576
597
  * Modifies the queue at the specified index.
577
598
  * @param start The index at which to start modifying the queue.
@@ -579,11 +600,11 @@ declare class MemoryQueue extends Array<Track> implements IQueue {
579
600
  * @param items The elements to add to the queue.
580
601
  * @returns The modified queue.
581
602
  */
582
- modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise<Track[]>;
603
+ modifyAt(start: number, deleteCount?: number, ...items: Track[]): Track[];
583
604
  /**
584
605
  * @returns The newest track.
585
606
  */
586
- popPrevious(): Promise<Track | null>;
607
+ popPrevious(): Track | null;
587
608
  /**
588
609
  * Removes track(s) from the queue.
589
610
  * @param startOrPosition If a single number is provided, it will be treated as the position of the track to remove.
@@ -591,45 +612,45 @@ declare class MemoryQueue extends Array<Track> implements IQueue {
591
612
  * @param end Optional, end of the range of tracks to remove.
592
613
  * @returns The removed track(s).
593
614
  */
594
- remove(position?: number): Promise<Track[]>;
595
- remove(start: number, end: number): Promise<Track[]>;
615
+ remove(position?: number): Track[];
616
+ remove(start: number, end: number): Track[];
596
617
  /**
597
618
  * Shuffles the queue to play tracks requested by each user one by one.
598
619
  */
599
- roundRobinShuffle(): Promise<void>;
620
+ roundRobinShuffle(): void;
600
621
  /**
601
622
  * @param track The track to set.
602
623
  */
603
- setCurrent(track: Track | null): Promise<void>;
624
+ setCurrent(track: Track | null): void;
604
625
  /**
605
626
  * @param tracks The tracks to set.
606
627
  */
607
- setPrevious(tracks: Track[]): Promise<void>;
628
+ setPrevious(tracks: Track[]): void;
608
629
  /**
609
630
  * Shuffles the queue.
610
631
  * This will randomize the order of the tracks in the queue and emit a state update event.
611
632
  */
612
- shuffle(): Promise<void>;
633
+ shuffle(): void;
613
634
  /**
614
635
  * The size of tracks in the queue.
615
636
  * This does not include the currently playing track.
616
637
  * @returns The size of tracks in the queue.
617
638
  */
618
- size(): Promise<number>;
639
+ size(): number;
619
640
  /**
620
641
  * @returns Whether at least one element in the queue satisfies the provided testing function.
621
642
  */
622
- someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
643
+ someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): boolean;
623
644
  /**
624
645
  * The total size of tracks in the queue including the current track.
625
646
  * This includes the current track if it is not null.
626
647
  * @returns The total size of tracks in the queue including the current track.
627
648
  */
628
- totalSize(): Promise<number>;
649
+ totalSize(): number;
629
650
  /**
630
651
  * Shuffles the queue to play tracks requested by each user one block at a time.
631
652
  */
632
- userBlockShuffle(): Promise<void>;
653
+ userBlockShuffle(): void;
633
654
  }
634
655
 
635
656
  /**
@@ -646,6 +667,10 @@ declare class RedisQueue implements IQueue {
646
667
  * The Redis instance.
647
668
  */
648
669
  private redis;
670
+ /**
671
+ * Whether the queue has been destroyed.
672
+ */
673
+ private destroyed;
649
674
  /**
650
675
  * Constructs a new RedisQueue.
651
676
  * @param guildId The guild ID.
@@ -675,6 +700,11 @@ declare class RedisQueue implements IQueue {
675
700
  * Removes the first track from the queue.
676
701
  */
677
702
  dequeue(): Promise<Track | undefined>;
703
+ /**
704
+ * Destroys the queue and releases all resources.
705
+ * After calling this method, the queue must not be used again.
706
+ */
707
+ destroy(): Promise<void>;
678
708
  /**
679
709
  * @returns The total duration of the queue in milliseconds.
680
710
  * This includes the duration of the currently playing track.
@@ -891,6 +921,12 @@ interface ManagerOptions {
891
921
  * @param payload The payload to send.
892
922
  */
893
923
  send?: (packet: DiscordPacket) => unknown;
924
+ /**
925
+ * Optional user cache getter.
926
+ * When resolving a user from a partial ID, this function will be called first.
927
+ * Should return the full user object if cached, or undefined if not.
928
+ */
929
+ getUser?: (id: string) => AnyUser | undefined;
894
930
  }
895
931
  /**
896
932
  * State Storage Options
@@ -1189,6 +1225,8 @@ interface Track {
1189
1225
  pluginInfo: TrackPluginInfo;
1190
1226
  /** Add your own data to the track. */
1191
1227
  customData: Record<string, unknown>;
1228
+ /** If the track got added by autoplay. */
1229
+ readonly isAutoplay: boolean;
1192
1230
  }
1193
1231
  /**
1194
1232
  * Track Plugin Info
@@ -1270,11 +1308,7 @@ interface LavaPlayer {
1270
1308
  connected: boolean;
1271
1309
  ping: number;
1272
1310
  };
1273
- voice: {
1274
- token: string;
1275
- endpoint: string;
1276
- sessionId: string;
1277
- };
1311
+ voice: LavalinkVoiceStateResponse;
1278
1312
  filters: Record<string, unknown>;
1279
1313
  }
1280
1314
  /**
@@ -1459,6 +1493,7 @@ interface VoiceState {
1459
1493
  guildId: string;
1460
1494
  event: VoiceServer;
1461
1495
  sessionId?: string;
1496
+ channelId?: string;
1462
1497
  }
1463
1498
  /**
1464
1499
  * Voice State
@@ -1878,15 +1913,29 @@ interface RestPlayOptions {
1878
1913
  /** The audio effects. */
1879
1914
  filters?: object;
1880
1915
  /** voice payload. */
1881
- voice?: {
1882
- token: string;
1883
- sessionId: string;
1884
- endpoint: string;
1885
- };
1916
+ voice?: LavalinkVoiceStateUpdate;
1886
1917
  /** Whether to not replace the track if a play payload is sent. */
1887
1918
  noReplace?: boolean;
1888
1919
  };
1889
1920
  }
1921
+ /**
1922
+ * Lavalink voice state response
1923
+ */
1924
+ type LavalinkVoiceStateResponse = {
1925
+ token: string;
1926
+ endpoint: string;
1927
+ sessionId: string;
1928
+ channelId: string | null;
1929
+ };
1930
+ /**
1931
+ * Lavalink voice state update
1932
+ */
1933
+ type LavalinkVoiceStateUpdate = {
1934
+ token: string;
1935
+ endpoint: string;
1936
+ sessionId: string;
1937
+ channelId: string;
1938
+ };
1890
1939
  /**
1891
1940
  * ManagerInitOptions interface
1892
1941
  */
@@ -1947,33 +1996,34 @@ interface ReverbOptions {
1947
1996
  * Queue interface
1948
1997
  */
1949
1998
  interface IQueue {
1950
- getCurrent(): Promise<Track | null>;
1951
- setCurrent(track: Track | null): Promise<void>;
1952
- getPrevious(): Promise<Track[]>;
1953
- addPrevious(track: Track | Track[]): Promise<void>;
1954
- setPrevious(track: Track | Track[]): Promise<void>;
1999
+ getCurrent(): Track | Promise<Track | null>;
2000
+ setCurrent(track: Track | null): void | Promise<void>;
2001
+ getPrevious(): Track[] | Promise<Track[]>;
2002
+ addPrevious(track: Track | Track[]): void | Promise<void>;
2003
+ setPrevious(track: Track | Track[]): void | Promise<void>;
1955
2004
  /** Get newest track (index 0) */
1956
- popPrevious(): Promise<Track | null>;
1957
- clearPrevious(): Promise<void>;
1958
- size(): Promise<number>;
1959
- totalSize(): Promise<number>;
1960
- duration(): Promise<number>;
1961
- add(track: Track | Track[], offset?: number): Promise<void>;
1962
- remove(start?: number, end?: number): Promise<Track[]>;
1963
- clear(): Promise<void>;
1964
- dequeue(): Promise<Track | undefined>;
1965
- enqueueFront(track: Track | Track[]): Promise<void>;
1966
- getTracks(): Promise<Track[]>;
1967
- getSlice(start?: number, end?: number): Promise<Track[]>;
1968
- modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise<Track[]>;
1969
- shuffle(): Promise<void>;
1970
- userBlockShuffle(): Promise<void>;
1971
- roundRobinShuffle(): Promise<void>;
1972
- mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
1973
- filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
1974
- findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
1975
- someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
1976
- everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
2005
+ popPrevious(): Track | Promise<Track | null>;
2006
+ clearPrevious(): void | Promise<void>;
2007
+ size(): number | Promise<number>;
2008
+ totalSize(): number | Promise<number>;
2009
+ duration(): number | Promise<number>;
2010
+ add(track: Track | Track[], offset?: number): void | Promise<void>;
2011
+ remove(start?: number, end?: number): Track[] | Promise<Track[]>;
2012
+ clear(): void | Promise<void>;
2013
+ dequeue(): Track | Promise<Track | undefined>;
2014
+ enqueueFront(track: Track | Track[]): void | Promise<void>;
2015
+ getTracks(): Track[] | Promise<Track[]>;
2016
+ getSlice(start?: number, end?: number): Track[] | Promise<Track[]>;
2017
+ modifyAt(start: number, deleteCount?: number, ...items: Track[]): Track[] | Promise<Track[]>;
2018
+ shuffle(): void | Promise<void>;
2019
+ userBlockShuffle(): void | Promise<void>;
2020
+ roundRobinShuffle(): void | Promise<void>;
2021
+ mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): T[] | Promise<T[]>;
2022
+ filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Track[] | Promise<Track[]>;
2023
+ findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Track | Promise<Track | undefined>;
2024
+ someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): boolean | Promise<boolean>;
2025
+ everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): boolean | Promise<boolean>;
2026
+ destroy(): void | Promise<void>;
1977
2027
  }
1978
2028
  /**
1979
2029
  * Sizes Enum type
@@ -2304,15 +2354,6 @@ declare class Player {
2304
2354
  * @returns {Promise<Player>} - The player instance after being moved.
2305
2355
  */
2306
2356
  moveNode(identifier: string): Promise<Player>;
2307
- /**
2308
- * Transfers the player to a new server. If the player already exists on the new server
2309
- * and force is false, this method will return the existing player. Otherwise, a new player
2310
- * will be created and the current player will be destroyed.
2311
- * @param {PlayerOptions} newOptions - The new options for the player.
2312
- * @param {boolean} force - Whether to force the creation of a new player.
2313
- * @returns {Promise<Player>} - The new player instance.
2314
- */
2315
- switchGuild(newOptions: PlayerOptions, force?: boolean): Promise<Player>;
2316
2357
  /**
2317
2358
  * Retrieves the data associated with the player.
2318
2359
  * @returns {Record<string, unknown>} - The data associated with the player.
@@ -2323,6 +2364,11 @@ declare class Player {
2323
2364
  * @returns {NodeJS.Timeout | null} - The dynamic loop interval of the player.
2324
2365
  */
2325
2366
  getDynamicLoopIntervalPublic(): NodeJS.Timeout | null;
2367
+ /**
2368
+ * Retrieves the data associated with the player.
2369
+ * @returns {Record<string, unknown>} - The data associated with the player.
2370
+ */
2371
+ getSerializableData(): Record<string, unknown>;
2326
2372
  /**
2327
2373
  * Retrieves the current lyrics for the playing track.
2328
2374
  * @param skipTrackSource - Indicates whether to skip the track source when fetching lyrics.
@@ -2487,7 +2533,6 @@ declare class Node {
2487
2533
  private reconnectTimeout?;
2488
2534
  private reconnectAttempts;
2489
2535
  private redisPrefix?;
2490
- private sessionIdsFilePath?;
2491
2536
  private sessionIdsMap;
2492
2537
  /**
2493
2538
  * Creates an instance of Node.
@@ -2502,12 +2547,10 @@ declare class Node {
2502
2547
  get connected(): boolean;
2503
2548
  /** Returns the full address for this node, including the host and port. */
2504
2549
  get address(): string;
2505
- /**
2506
- * Creates the sessionIds.json file if it doesn't exist. This file is used to
2507
- * store the session IDs for each node. The session IDs are used to identify
2508
- * the node when resuming a session.
2509
- */
2510
- createSessionIdsFile(): void;
2550
+ private getCompositeKey;
2551
+ private getRedisSessionIdsKey;
2552
+ private getNodeSessionsDir;
2553
+ private getNodeSessionPath;
2511
2554
  /**
2512
2555
  * Loads session IDs from the sessionIds.json file if it exists.
2513
2556
  * The session IDs are used to resume sessions for each node.
@@ -2529,6 +2572,8 @@ declare class Node {
2529
2572
  * be used with the same node identifier.
2530
2573
  */
2531
2574
  updateSessionId(): Promise<void>;
2575
+ private updateSessionIdFile;
2576
+ private updateSessionIdRedis;
2532
2577
  /**
2533
2578
  * Connects to the Node.
2534
2579
  *
@@ -2867,6 +2912,7 @@ declare class Manager extends EventEmitter {
2867
2912
  initiated: boolean;
2868
2913
  redis?: Redis;
2869
2914
  private _send;
2915
+ private _getUser?;
2870
2916
  private loadedPlugins;
2871
2917
  /**
2872
2918
  * Initiates the Manager class.
@@ -3089,6 +3135,7 @@ declare class Manager extends EventEmitter {
3089
3135
  */
3090
3136
  private get priorityNode();
3091
3137
  protected send(packet: GatewayVoiceStateUpdate): unknown;
3138
+ protected getUserFromCache(id: string): AnyUser | undefined;
3092
3139
  sendPacket(packet: GatewayVoiceStateUpdate): unknown;
3093
3140
  /**
3094
3141
  * Resolves a PortableUser or ID to a real user object.
@@ -3101,8 +3148,6 @@ declare class Filters {
3101
3148
  distortion: DistortionOptions | null;
3102
3149
  equalizer: Band[];
3103
3150
  karaoke: KaraokeOptions | null;
3104
- manager: Manager;
3105
- player: Player;
3106
3151
  rotation: RotationOptions | null;
3107
3152
  timescale: TimescaleOptions | null;
3108
3153
  vibrato: VibratoOptions | null;
@@ -3110,6 +3155,8 @@ declare class Filters {
3110
3155
  volume: number;
3111
3156
  bassBoostlevel: number;
3112
3157
  filtersStatus: Record<AvailableFilters, boolean>;
3158
+ manager: Manager;
3159
+ player: Player;
3113
3160
  constructor(player: Player, manager: Manager);
3114
3161
  /**
3115
3162
  * Updates the player's audio filters.
@@ -3462,18 +3509,30 @@ declare abstract class TrackUtils {
3462
3509
  static setTrackPartial(partial: TrackPartial[]): void;
3463
3510
  /**
3464
3511
  * Checks if the provided argument is a valid Track.
3465
- * If provided an array then every element will be checked.
3466
- * @param trackOrTracks The Track or array of Tracks to check.
3512
+ * @param value The value to check.
3467
3513
  * @returns {boolean} Whether the provided argument is a valid Track.
3468
3514
  */
3469
- static validate(trackOrTracks: unknown): boolean;
3515
+ static isTrack(track: unknown): track is Track;
3516
+ /**
3517
+ * Checks if the provided argument is a valid Track array.
3518
+ * @param value The value to check.
3519
+ * @returns {boolean} Whether the provided argument is a valid Track array.
3520
+ */
3521
+ static isTrackArray(value: unknown): value is Track[];
3522
+ /**
3523
+ * Checks if the provided argument is a valid Track or Track array.
3524
+ * @param value The value to check.
3525
+ * @returns {boolean} Whether the provided argument is a valid Track or Track array.
3526
+ */
3527
+ static validate(value: unknown): value is Track | Track[];
3470
3528
  /**
3471
3529
  * Builds a Track from the raw data from Lavalink and a optional requester.
3472
3530
  * @param data The raw data from Lavalink to build the Track from.
3473
3531
  * @param requester The user who requested the track, if any.
3532
+ * @param isAutoPlay Whether the track is autoplayed. Defaults to false.
3474
3533
  * @returns The built Track.
3475
3534
  */
3476
- static build<T = AnyUser>(data: TrackData, requester?: T): Track;
3535
+ static build<T = AnyUser>(data: TrackData, requester?: T, isAutoplay?: boolean): Track;
3477
3536
  /**
3478
3537
  * Validates a search result.
3479
3538
  * @param result The search result to validate.
@@ -3550,7 +3609,7 @@ declare abstract class PlayerUtils {
3550
3609
  * @param player The Player instance to serialize
3551
3610
  * @returns The serialized Player instance
3552
3611
  */
3553
- static serializePlayer(player: Player): Promise<Record<string, unknown>>;
3612
+ static serializePlayer(player: Player): Promise<Record<string, unknown> | null>;
3554
3613
  /**
3555
3614
  * Gets the base directory for player data.
3556
3615
  */
@@ -3575,6 +3634,10 @@ declare abstract class PlayerUtils {
3575
3634
  * Gets the path to the player's previous tracks file.
3576
3635
  */
3577
3636
  static getPlayerPreviousPath(guildId: string): string;
3637
+ /**
3638
+ * Gets the Redis key for player storage.
3639
+ */
3640
+ static getRedisKey(): string;
3578
3641
  }
3579
3642
  /** Gets or extends structures to extend the built in, or already extended, classes to add more functionality. */
3580
3643
  declare abstract class Structure {
@@ -3608,6 +3671,20 @@ declare class MagmaStreamError<T = unknown> extends Error {
3608
3671
  constructor({ code, message, cause, context }: MagmaStreamErrorOptions<T>);
3609
3672
  }
3610
3673
 
3674
+ /**
3675
+ * Discordeno wrapper for Magmastream.
3676
+ */
3677
+ declare class DiscordenoManager extends Manager {
3678
+ readonly client: Bot;
3679
+ constructor(client: Bot, options?: ManagerOptions);
3680
+ protected send(packet: GatewayVoiceStateUpdate): void;
3681
+ /**
3682
+ * Resolve a user by ID or partial info.
3683
+ * Uses user-provided cache getter if available, otherwise falls back to minimal info.
3684
+ */
3685
+ resolveUser(user: AnyUser | string): Promise<User$2 | AnyUser>;
3686
+ }
3687
+
3611
3688
  /**
3612
3689
  * Discord.js wrapper for Magmastream.
3613
3690
  */
@@ -3628,16 +3705,6 @@ declare class ErisManager extends Manager {
3628
3705
  resolveUser(user: AnyUser | string): Promise<User$3 | AnyUser>;
3629
3706
  }
3630
3707
 
3631
- /**
3632
- * Detritus wrapper for Magmastream.
3633
- */
3634
- declare class DetritusManager extends Manager {
3635
- readonly client: ClusterClient | ShardClient;
3636
- constructor(client: ClusterClient | ShardClient, options?: ManagerOptions);
3637
- protected send(packet: GatewayVoiceStateUpdate): void;
3638
- resolveUser(user: AnyUser | string): Promise<AnyUser>;
3639
- }
3640
-
3641
3708
  /**
3642
3709
  * Oceanic wrapper for Magmastream.
3643
3710
  */
@@ -3680,5 +3747,5 @@ declare class SeyfertManager extends Manager {
3680
3747
  resolveUser(user: AnyUser | string): Promise<User$4 | AnyUser>;
3681
3748
  }
3682
3749
 
3683
- export { AutoPlayPlatform, AutoPlayUtils, AvailableFilters, DetritusManager, DiscordJSManager, ErisManager, Filters, JSONUtils, JsonQueue, LoadTypes, MagmaStreamError, MagmaStreamErrorCode, MagmaStreamErrorNumbers, Manager, ManagerEventTypes, MemoryQueue, Node, OceanicManager, Player, PlayerStateEventTypes, PlayerUtils, Plugin, RedisQueue, Rest, SearchPlatform, SeverityTypes, SeyfertManager, SponsorBlockSegment, StateStorageType, StateTypes, Structure, TrackEndReasonTypes, TrackPartial, TrackSourceTypes, TrackUtils, UseNodeOptions };
3684
- export type { AlbumSearchResult, AnyMessage, AnyUser, ArtistSearchResult, CPUStats, DiscordPacket, DistortionOptions, EndSpeakingEventVoiceReceiver, EndSpeakingEventVoiceReceiverData, EqualizerBand, ErrorOrEmptySearchResult, Exception, Extendable, FrameStats, IQueue, JsonConfig, KaraokeOptions, LavaPlayer, LavalinkInfo, LavalinkResponse, LoadType, Lyrics, LyricsEvent, LyricsEventType, LyricsFoundEvent, LyricsLine, LyricsLineEvent, LyricsNotFoundEvent, ManagerEvents, ManagerInitOptions, ManagerOptions, MemoryStats, NodeLinkGetLyrics, NodeLinkGetLyricsEmpty, NodeLinkGetLyricsError, NodeLinkGetLyricsMultiple, NodeLinkGetLyricsSingle, NodeMessage, NodeOptions, NodeStats, PlayOptions, PlayerEvent, PlayerEventType, PlayerEvents, PlayerOptions, PlayerStateUpdateEvent, PlayerUpdateVoiceState, PlaylistData, PlaylistInfoData, PlaylistRawData, PlaylistSearchResult, PodcastSearchResult, PortableMessage, PortableUser, RedisConfig, RestPlayOptions, ReverbOptions, RotationOptions, SearchQuery, SearchResult, SearchSearchResult, Severity, ShortSearchResult, ShowSearchResult, Sizes, SponsorBlockChapterStarted, SponsorBlockChaptersLoaded, SponsorBlockSegmentEventType, SponsorBlockSegmentEvents, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, StartSpeakingEventVoiceReceiver, StartSpeakingEventVoiceReceiverData, StateStorageOptions, StationSearchResult, TimescaleOptions, Track, TrackData, TrackDataInfo, TrackEndEvent, TrackEndReason, TrackExceptionEvent, TrackPluginInfo, TrackSearchResult, TrackSourceName, TrackStartEvent, TrackStuckEvent, UseNodeOption, VibratoOptions, VoicePacket, VoiceReceiverEvent, VoiceServer, VoiceServerUpdate, VoiceState, WebSocketClosedEvent };
3750
+ export { AutoPlayPlatform, AutoPlayUtils, AvailableFilters, DiscordJSManager, DiscordenoManager, ErisManager, Filters, JSONUtils, JsonQueue, LoadTypes, MagmaStreamError, MagmaStreamErrorCode, MagmaStreamErrorNumbers, Manager, ManagerEventTypes, MemoryQueue, Node, OceanicManager, Player, PlayerStateEventTypes, PlayerUtils, Plugin, RedisQueue, Rest, SearchPlatform, SeverityTypes, SeyfertManager, SponsorBlockSegment, StateStorageType, StateTypes, Structure, TrackEndReasonTypes, TrackPartial, TrackSourceTypes, TrackUtils, UseNodeOptions };
3751
+ export type { AlbumSearchResult, AnyMessage, AnyUser, ArtistSearchResult, CPUStats, DiscordPacket, DistortionOptions, EndSpeakingEventVoiceReceiver, EndSpeakingEventVoiceReceiverData, EqualizerBand, ErrorOrEmptySearchResult, Exception, Extendable, FrameStats, IQueue, JsonConfig, KaraokeOptions, LavaPlayer, LavalinkInfo, LavalinkResponse, LavalinkVoiceStateResponse, LavalinkVoiceStateUpdate, LoadType, Lyrics, LyricsEvent, LyricsEventType, LyricsFoundEvent, LyricsLine, LyricsLineEvent, LyricsNotFoundEvent, ManagerEvents, ManagerInitOptions, ManagerOptions, MemoryStats, NodeLinkGetLyrics, NodeLinkGetLyricsEmpty, NodeLinkGetLyricsError, NodeLinkGetLyricsMultiple, NodeLinkGetLyricsSingle, NodeMessage, NodeOptions, NodeStats, PlayOptions, PlayerEvent, PlayerEventType, PlayerEvents, PlayerOptions, PlayerStateUpdateEvent, PlayerUpdateVoiceState, PlaylistData, PlaylistInfoData, PlaylistRawData, PlaylistSearchResult, PodcastSearchResult, PortableMessage, PortableUser, RedisConfig, RestPlayOptions, ReverbOptions, RotationOptions, SearchQuery, SearchResult, SearchSearchResult, Severity, ShortSearchResult, ShowSearchResult, Sizes, SponsorBlockChapterStarted, SponsorBlockChaptersLoaded, SponsorBlockSegmentEventType, SponsorBlockSegmentEvents, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, StartSpeakingEventVoiceReceiver, StartSpeakingEventVoiceReceiverData, StateStorageOptions, StationSearchResult, TimescaleOptions, Track, TrackData, TrackDataInfo, TrackEndEvent, TrackEndReason, TrackExceptionEvent, TrackPluginInfo, TrackSearchResult, TrackSourceName, TrackStartEvent, TrackStuckEvent, UseNodeOption, VibratoOptions, VoicePacket, VoiceReceiverEvent, VoiceServer, VoiceServerUpdate, VoiceState, WebSocketClosedEvent };
package/dist/index.js CHANGED
@@ -11,9 +11,9 @@ tslib_1.__exportStar(require("./structures/Rest"), exports);
11
11
  tslib_1.__exportStar(require("./structures/Utils"), exports);
12
12
  tslib_1.__exportStar(require("./structures/MagmastreamError"), exports);
13
13
  // wrappers
14
+ tslib_1.__exportStar(require("./wrappers/discordeno"), exports);
14
15
  tslib_1.__exportStar(require("./wrappers/discord.js"), exports);
15
16
  tslib_1.__exportStar(require("./wrappers/eris"), exports);
16
- tslib_1.__exportStar(require("./wrappers/detritus"), exports);
17
17
  tslib_1.__exportStar(require("./wrappers/oceanic"), exports);
18
18
  tslib_1.__exportStar(require("./wrappers/seyfert"), exports);
19
19
  // types
@@ -17,6 +17,10 @@ class JsonQueue {
17
17
  * The base path for the queue files.
18
18
  */
19
19
  basePath;
20
+ /**
21
+ * Whether the queue has been destroyed.
22
+ */
23
+ destroyed = false;
20
24
  /**
21
25
  * @param guildId The guild ID.
22
26
  * @param manager The manager.
@@ -56,8 +60,7 @@ class JsonQueue {
56
60
  this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[JSONQUEUE] Added ${tracks.length} track(s) to queue`);
57
61
  if (this.manager.players.has(this.guildId) && this.manager.players.get(this.guildId).isAutoplay) {
58
62
  if (!isArray) {
59
- const AutoplayUser = (await this.manager.players.get(this.guildId).get("Internal_AutoplayUser"));
60
- if (AutoplayUser && AutoplayUser.id === track.requester.id) {
63
+ if (track.isAutoplay) {
61
64
  this.manager.emit(Enums_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guildId), {
62
65
  changeType: Enums_1.PlayerStateEventTypes.QueueChange,
63
66
  details: {
@@ -173,6 +176,27 @@ class JsonQueue {
173
176
  console.error(error);
174
177
  }
175
178
  }
179
+ /**
180
+ * Destroys the queue and releases all resources.
181
+ * After calling this method, the queue must not be used again.
182
+ */
183
+ async destroy() {
184
+ if (this.destroyed)
185
+ return;
186
+ this.destroyed = true;
187
+ try {
188
+ await Promise.all([this.deleteFile(this.queuePath), this.deleteFile(this.currentPath), this.deleteFile(this.previousPath)]);
189
+ }
190
+ catch (err) {
191
+ console.error(err instanceof MagmastreamError_1.MagmaStreamError
192
+ ? err
193
+ : new MagmastreamError_1.MagmaStreamError({
194
+ code: Enums_1.MagmaStreamErrorCode.QUEUE_JSON_ERROR,
195
+ message: `Failed to destroy JSONQueue for guild ${this.guildId}`,
196
+ cause: err,
197
+ }));
198
+ }
199
+ }
176
200
  /**
177
201
  * @returns The total duration of the queue.
178
202
  */
@@ -349,7 +373,7 @@ class JsonQueue {
349
373
  const queue = await this.getQueue();
350
374
  const userMap = new Map();
351
375
  for (const track of queue) {
352
- const userId = track.requester.id;
376
+ const userId = track.requester.id.toString();
353
377
  if (!userMap.has(userId))
354
378
  userMap.set(userId, []);
355
379
  userMap.get(userId).push(track);
@@ -474,7 +498,7 @@ class JsonQueue {
474
498
  const queue = await this.getQueue();
475
499
  const userMap = new Map();
476
500
  for (const track of queue) {
477
- const userId = track.requester.id;
501
+ const userId = track.requester.id.toString();
478
502
  if (!userMap.has(userId))
479
503
  userMap.set(userId, []);
480
504
  userMap.get(userId).push(track);