magmastream 2.9.3-dev.14 → 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 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 {
@@ -286,6 +285,7 @@ declare enum MagmaStreamErrorCode {
286
285
  GENERAL_UNKNOWN = "MS_GENERAL_UNKNOWN",
287
286
  GENERAL_TIMEOUT = "MS_GENERAL_TIMEOUT",
288
287
  GENERAL_INVALID_MANAGER = "MS_GENERAL_INVALID_MANAGER",
288
+ INTENT_MISSING = "MS_INTENT_MISSING",
289
289
  MANAGER_INIT_FAILED = "MS_MANAGER_INIT_FAILED",
290
290
  MANAGER_INVALID_CONFIG = "MS_MANAGER_INVALID_CONFIG",
291
291
  MANAGER_SHUTDOWN_FAILED = "MS_MANAGER_SHUTDOWN_FAILED",
@@ -921,6 +921,12 @@ interface ManagerOptions {
921
921
  * @param payload The payload to send.
922
922
  */
923
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;
924
930
  }
925
931
  /**
926
932
  * State Storage Options
@@ -2337,15 +2343,6 @@ declare class Player {
2337
2343
  * @returns {Promise<Player>} - The player instance after being moved.
2338
2344
  */
2339
2345
  moveNode(identifier: string): Promise<Player>;
2340
- /**
2341
- * Transfers the player to a new server. If the player already exists on the new server
2342
- * and force is false, this method will return the existing player. Otherwise, a new player
2343
- * will be created and the current player will be destroyed.
2344
- * @param {PlayerOptions} newOptions - The new options for the player.
2345
- * @param {boolean} force - Whether to force the creation of a new player.
2346
- * @returns {Promise<Player>} - The new player instance.
2347
- */
2348
- switchGuild(newOptions: PlayerOptions, force?: boolean): Promise<Player>;
2349
2346
  /**
2350
2347
  * Retrieves the data associated with the player.
2351
2348
  * @returns {Record<string, unknown>} - The data associated with the player.
@@ -2905,6 +2902,7 @@ declare class Manager extends EventEmitter {
2905
2902
  initiated: boolean;
2906
2903
  redis?: Redis;
2907
2904
  private _send;
2905
+ private _getUser?;
2908
2906
  private loadedPlugins;
2909
2907
  /**
2910
2908
  * Initiates the Manager class.
@@ -3127,6 +3125,7 @@ declare class Manager extends EventEmitter {
3127
3125
  */
3128
3126
  private get priorityNode();
3129
3127
  protected send(packet: GatewayVoiceStateUpdate): unknown;
3128
+ protected getUserFromCache(id: string): AnyUser | undefined;
3130
3129
  sendPacket(packet: GatewayVoiceStateUpdate): unknown;
3131
3130
  /**
3132
3131
  * Resolves a PortableUser or ID to a real user object.
@@ -3658,6 +3657,20 @@ declare class MagmaStreamError<T = unknown> extends Error {
3658
3657
  constructor({ code, message, cause, context }: MagmaStreamErrorOptions<T>);
3659
3658
  }
3660
3659
 
3660
+ /**
3661
+ * Discordeno wrapper for Magmastream.
3662
+ */
3663
+ declare class DiscordenoManager extends Manager {
3664
+ readonly client: Bot;
3665
+ constructor(client: Bot, options?: ManagerOptions);
3666
+ protected send(packet: GatewayVoiceStateUpdate): void;
3667
+ /**
3668
+ * Resolve a user by ID or partial info.
3669
+ * Uses user-provided cache getter if available, otherwise falls back to minimal info.
3670
+ */
3671
+ resolveUser(user: AnyUser | string): Promise<User$2 | AnyUser>;
3672
+ }
3673
+
3661
3674
  /**
3662
3675
  * Discord.js wrapper for Magmastream.
3663
3676
  */
@@ -3678,16 +3691,6 @@ declare class ErisManager extends Manager {
3678
3691
  resolveUser(user: AnyUser | string): Promise<User$3 | AnyUser>;
3679
3692
  }
3680
3693
 
3681
- /**
3682
- * Detritus wrapper for Magmastream.
3683
- */
3684
- declare class DetritusManager extends Manager {
3685
- readonly client: ClusterClient | ShardClient;
3686
- constructor(client: ClusterClient | ShardClient, options?: ManagerOptions);
3687
- protected send(packet: GatewayVoiceStateUpdate): void;
3688
- resolveUser(user: AnyUser | string): Promise<AnyUser>;
3689
- }
3690
-
3691
3694
  /**
3692
3695
  * Oceanic wrapper for Magmastream.
3693
3696
  */
@@ -3730,5 +3733,5 @@ declare class SeyfertManager extends Manager {
3730
3733
  resolveUser(user: AnyUser | string): Promise<User$4 | AnyUser>;
3731
3734
  }
3732
3735
 
3733
- 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 };
3736
+ 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 };
3734
3737
  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 };
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
@@ -373,7 +373,7 @@ class JsonQueue {
373
373
  const queue = await this.getQueue();
374
374
  const userMap = new Map();
375
375
  for (const track of queue) {
376
- const userId = track.requester.id;
376
+ const userId = track.requester.id.toString();
377
377
  if (!userMap.has(userId))
378
378
  userMap.set(userId, []);
379
379
  userMap.get(userId).push(track);
@@ -498,7 +498,7 @@ class JsonQueue {
498
498
  const queue = await this.getQueue();
499
499
  const userMap = new Map();
500
500
  for (const track of queue) {
501
- const userId = track.requester.id;
501
+ const userId = track.requester.id.toString();
502
502
  if (!userMap.has(userId))
503
503
  userMap.set(userId, []);
504
504
  userMap.get(userId).push(track);
@@ -355,11 +355,11 @@ class MemoryQueue extends Array {
355
355
  const userTracks = new Map();
356
356
  // Group the tracks in the queue by the user that requested them.
357
357
  this.forEach((track) => {
358
- const user = track.requester.id;
359
- if (!userTracks.has(user)) {
360
- userTracks.set(user, []);
358
+ const userId = track.requester.id.toString();
359
+ if (!userTracks.has(userId)) {
360
+ userTracks.set(userId, []);
361
361
  }
362
- userTracks.get(user).push(track);
362
+ userTracks.get(userId).push(track);
363
363
  });
364
364
  // Shuffle the tracks of each user.
365
365
  userTracks.forEach((tracks) => {
@@ -486,11 +486,11 @@ class MemoryQueue extends Array {
486
486
  // Group the tracks in the queue by the user that requested them.
487
487
  const userTracks = new Map();
488
488
  this.forEach((track) => {
489
- const user = track.requester.id;
490
- if (!userTracks.has(user)) {
491
- userTracks.set(user, []);
489
+ const userId = track.requester.id.toString();
490
+ if (!userTracks.has(userId)) {
491
+ userTracks.set(userId, []);
492
492
  }
493
- userTracks.get(user).push(track);
493
+ userTracks.get(userId).push(track);
494
494
  });
495
495
  // Create a new array for the shuffled queue.
496
496
  const shuffledQueue = [];
@@ -513,7 +513,7 @@ class RedisQueue {
513
513
  const deserialized = rawTracks.map(this.deserialize);
514
514
  const userMap = new Map();
515
515
  for (const track of deserialized) {
516
- const userId = track.requester.id;
516
+ const userId = track.requester.id.toString();
517
517
  if (!userMap.has(userId))
518
518
  userMap.set(userId, []);
519
519
  userMap.get(userId).push(track);
@@ -684,7 +684,7 @@ class RedisQueue {
684
684
  const deserialized = rawTracks.map(this.deserialize);
685
685
  const userMap = new Map();
686
686
  for (const track of deserialized) {
687
- const userId = track.requester.id;
687
+ const userId = track.requester.id.toString();
688
688
  if (!userMap.has(userId))
689
689
  userMap.set(userId, []);
690
690
  userMap.get(userId).push(track);
@@ -285,6 +285,7 @@ var MagmaStreamErrorCode;
285
285
  MagmaStreamErrorCode["GENERAL_UNKNOWN"] = "MS_GENERAL_UNKNOWN";
286
286
  MagmaStreamErrorCode["GENERAL_TIMEOUT"] = "MS_GENERAL_TIMEOUT";
287
287
  MagmaStreamErrorCode["GENERAL_INVALID_MANAGER"] = "MS_GENERAL_INVALID_MANAGER";
288
+ MagmaStreamErrorCode["INTENT_MISSING"] = "MS_INTENT_MISSING";
288
289
  // MANAGER (1100)
289
290
  MagmaStreamErrorCode["MANAGER_INIT_FAILED"] = "MS_MANAGER_INIT_FAILED";
290
291
  MagmaStreamErrorCode["MANAGER_INVALID_CONFIG"] = "MS_MANAGER_INVALID_CONFIG";
@@ -339,6 +340,7 @@ exports.MagmaStreamErrorNumbers = {
339
340
  [MagmaStreamErrorCode.GENERAL_UNKNOWN]: 1000,
340
341
  [MagmaStreamErrorCode.GENERAL_TIMEOUT]: 1001,
341
342
  [MagmaStreamErrorCode.GENERAL_INVALID_MANAGER]: 1002,
343
+ [MagmaStreamErrorCode.INTENT_MISSING]: 1003,
342
344
  // MANAGER
343
345
  [MagmaStreamErrorCode.MANAGER_INIT_FAILED]: 1100,
344
346
  [MagmaStreamErrorCode.MANAGER_INVALID_CONFIG]: 1101,
@@ -28,6 +28,7 @@ class Manager extends events_1.EventEmitter {
28
28
  initiated = false;
29
29
  redis;
30
30
  _send;
31
+ _getUser;
31
32
  loadedPlugins = new Set();
32
33
  /**
33
34
  * Initiates the Manager class.
@@ -61,6 +62,8 @@ class Manager extends events_1.EventEmitter {
61
62
  this.options.clusterId = options.clusterId;
62
63
  if (options.send && !this._send)
63
64
  this._send = options.send;
65
+ if (options.getUser && !this._getUser)
66
+ this._getUser = options.getUser;
64
67
  this.options = {
65
68
  ...options,
66
69
  enabledPlugins: options.enabledPlugins ?? [],
@@ -1439,6 +1442,9 @@ class Manager extends events_1.EventEmitter {
1439
1442
  }
1440
1443
  return this._send(packet);
1441
1444
  }
1445
+ getUserFromCache(id) {
1446
+ return this._getUser?.(id);
1447
+ }
1442
1448
  sendPacket(packet) {
1443
1449
  return this.send(packet);
1444
1450
  }
@@ -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();
@@ -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.
@@ -4,7 +4,10 @@ exports.DiscordJSManager = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const Manager_1 = require("../structures/Manager");
6
6
  const discord_js_1 = require("discord.js");
7
- const [major, minor] = discord_js_1.version.split(".").map(Number);
7
+ const discord_js_2 = require("discord.js");
8
+ const MagmastreamError_1 = require("../structures/MagmastreamError");
9
+ const Enums_1 = require("../structures/Enums");
10
+ const [major, minor] = discord_js_2.version.split(".").map(Number);
8
11
  tslib_1.__exportStar(require("../index"), exports);
9
12
  /**
10
13
  * Discord.js wrapper for Magmastream.
@@ -14,6 +17,12 @@ class DiscordJSManager extends Manager_1.Manager {
14
17
  constructor(client, options) {
15
18
  super(options);
16
19
  this.client = client;
20
+ if (!this.client.options.intents.has(discord_js_1.GatewayIntentBits.GuildVoiceStates)) {
21
+ throw new MagmastreamError_1.MagmaStreamError({
22
+ code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
23
+ message: "[Custom Wrapper] Your Discord.js client must have the GuildVoiceStates intent enabled.",
24
+ });
25
+ }
17
26
  const attachReadyHandler = () => {
18
27
  const handler = () => {
19
28
  if (!this.options.clientId)
@@ -21,11 +30,11 @@ class DiscordJSManager extends Manager_1.Manager {
21
30
  };
22
31
  // Only attach clientReady if Discord.js >= 14.22.0
23
32
  if (major > 14 || (major === 14 && minor >= 22)) {
24
- client.once("clientReady", handler);
33
+ this.client.once("clientReady", handler);
25
34
  }
26
35
  // Only attach ready if Discord.js < 14.22.0
27
36
  if (major < 14 || (major === 14 && minor < 22)) {
28
- client.once("ready", handler);
37
+ this.client.once("ready", handler);
29
38
  }
30
39
  };
31
40
  attachReadyHandler();
@@ -39,7 +48,7 @@ class DiscordJSManager extends Manager_1.Manager {
39
48
  guild.shard.send(packet);
40
49
  }
41
50
  async resolveUser(user) {
42
- const id = typeof user === "string" ? user : user.id;
51
+ const id = typeof user === "string" ? user : String(user.id);
43
52
  const cached = this.client.users.cache.get(id);
44
53
  if (cached)
45
54
  return cached;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DiscordenoManager = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const Manager_1 = require("../structures/Manager");
6
+ const bot_1 = require("@discordeno/bot");
7
+ const Enums_1 = require("../structures/Enums");
8
+ const MagmastreamError_1 = require("../structures/MagmastreamError");
9
+ tslib_1.__exportStar(require("../index"), exports);
10
+ /**
11
+ * Discordeno wrapper for Magmastream.
12
+ */
13
+ class DiscordenoManager extends Manager_1.Manager {
14
+ client;
15
+ constructor(client, options) {
16
+ super(options);
17
+ this.client = client;
18
+ // Ensure GuildVoiceStates intent is enabled
19
+ const intents = this.client.gateway.intents;
20
+ if (!(intents & bot_1.GatewayIntents.GuildVoiceStates)) {
21
+ throw new MagmastreamError_1.MagmaStreamError({
22
+ code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
23
+ message: "[Custom Wrapper] Your Discordeno client must have the GuildVoiceStates intent enabled.",
24
+ });
25
+ }
26
+ // Chain READY event
27
+ const oldReady = this.client.handlers.READY;
28
+ this.client.handlers.READY = (bot, payload, shardId) => {
29
+ if (oldReady)
30
+ oldReady(bot, payload, shardId);
31
+ if (!this.options?.clientId)
32
+ this.options.clientId = this.client.applicationId.toString();
33
+ };
34
+ // Chain VOICE_STATE_UPDATE event
35
+ const oldVoiceState = this.client.handlers.VOICE_STATE_UPDATE;
36
+ this.client.handlers.VOICE_STATE_UPDATE = (bot, payload, shardId) => {
37
+ if (oldVoiceState)
38
+ oldVoiceState(bot, payload, shardId);
39
+ this.updateVoiceState(payload);
40
+ };
41
+ // Chain VOICE_SERVER_UPDATE event
42
+ const oldVoiceServer = this.client.handlers.VOICE_SERVER_UPDATE;
43
+ this.client.handlers.VOICE_SERVER_UPDATE = (bot, payload, shardId) => {
44
+ if (oldVoiceServer)
45
+ oldVoiceServer(bot, payload, shardId);
46
+ this.updateVoiceState(payload);
47
+ };
48
+ }
49
+ // Send voice state updates to the guild shard
50
+ send(packet) {
51
+ this.client.gateway.sendPayload(this.client.gateway.calculateShardId(packet.d.guild_id), {
52
+ op: bot_1.GatewayOpcodes.VoiceStateUpdate,
53
+ d: packet.d,
54
+ });
55
+ }
56
+ /**
57
+ * Resolve a user by ID or partial info.
58
+ * Uses user-provided cache getter if available, otherwise falls back to minimal info.
59
+ */
60
+ async resolveUser(user) {
61
+ const id = typeof user === "string" ? user : String(user.id);
62
+ // Try user-provided cache getter
63
+ const cached = this.getUserFromCache(id);
64
+ if (cached)
65
+ return cached;
66
+ // Fallback: return minimal info
67
+ return {
68
+ id,
69
+ username: typeof user === "string" ? undefined : user.username,
70
+ };
71
+ }
72
+ }
73
+ exports.DiscordenoManager = DiscordenoManager;
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ErisManager = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const v10_1 = require("discord-api-types/v10");
5
6
  const Manager_1 = require("../structures/Manager");
7
+ const Enums_1 = require("../structures/Enums");
8
+ const MagmastreamError_1 = require("../structures/MagmastreamError");
6
9
  tslib_1.__exportStar(require("../index"), exports);
7
10
  /**
8
11
  * Eris wrapper for Magmastream.
@@ -12,11 +15,19 @@ class ErisManager extends Manager_1.Manager {
12
15
  constructor(client, options) {
13
16
  super(options);
14
17
  this.client = client;
15
- client.once("ready", () => {
18
+ const intents = this.client.options.intents;
19
+ const hasGuildVoiceStates = typeof intents === "number" ? (intents & v10_1.GatewayIntentBits.GuildVoiceStates) === v10_1.GatewayIntentBits.GuildVoiceStates : intents.includes("guildVoiceStates");
20
+ if (!hasGuildVoiceStates) {
21
+ throw new MagmastreamError_1.MagmaStreamError({
22
+ code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
23
+ message: "[Custom Wrapper] Your Eris client must have the guildVoiceStates intent enabled.",
24
+ });
25
+ }
26
+ this.client.once("ready", () => {
16
27
  if (!this.options.clientId)
17
28
  this.options.clientId = client.user.id;
18
29
  });
19
- client.on("rawWS", async (packet) => {
30
+ this.client.on("rawWS", async (packet) => {
20
31
  await this.updateVoiceState(packet);
21
32
  });
22
33
  }
@@ -26,7 +37,7 @@ class ErisManager extends Manager_1.Manager {
26
37
  guild.shard.sendWS(packet.op, packet.d);
27
38
  }
28
39
  async resolveUser(user) {
29
- const id = typeof user === "string" ? user : user.id;
40
+ const id = typeof user === "string" ? user : String(user.id);
30
41
  const cached = this.client.users.get(id);
31
42
  if (cached)
32
43
  return cached;
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OceanicManager = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const Manager_1 = require("../structures/Manager");
6
+ const oceanic_js_1 = require("oceanic.js");
7
+ const Enums_1 = require("../structures/Enums");
8
+ const MagmastreamError_1 = require("../structures/MagmastreamError");
6
9
  tslib_1.__exportStar(require("../index"), exports);
7
10
  /**
8
11
  * Oceanic wrapper for Magmastream.
@@ -12,11 +15,20 @@ class OceanicManager extends Manager_1.Manager {
12
15
  constructor(client, options) {
13
16
  super(options);
14
17
  this.client = client;
15
- client.once("ready", () => {
18
+ const intents = this.client.shards.options.intents;
19
+ const { Intents } = oceanic_js_1.Constants;
20
+ const hasGuildVoiceStates = typeof intents === "number" ? (intents & Intents.GUILD_VOICE_STATES) === Intents.GUILD_VOICE_STATES : intents.includes("GUILD_VOICE_STATES");
21
+ if (!hasGuildVoiceStates) {
22
+ throw new MagmastreamError_1.MagmaStreamError({
23
+ code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
24
+ message: "[Custom Wrapper] Your Oceanic client must have the GUILD_VOICE_STATES intent enabled.",
25
+ });
26
+ }
27
+ this.client.once("ready", () => {
16
28
  if (!this.options.clientId)
17
- this.options.clientId = client.user.id;
29
+ this.options.clientId = this.client.user.id;
18
30
  });
19
- client.on("packet", async (packet) => {
31
+ this.client.on("packet", async (packet) => {
20
32
  await this.updateVoiceState(packet);
21
33
  });
22
34
  }
@@ -26,7 +38,7 @@ class OceanicManager extends Manager_1.Manager {
26
38
  guild.shard.send(packet.op, packet.d);
27
39
  }
28
40
  async resolveUser(user) {
29
- const id = typeof user === "string" ? user : user.id;
41
+ const id = typeof user === "string" ? user : String(user.id);
30
42
  const cached = this.client.users.get(id);
31
43
  if (cached)
32
44
  return cached;
@@ -4,7 +4,10 @@ exports.SeyfertManager = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const Manager_1 = require("../structures/Manager");
6
6
  const seyfert_1 = require("seyfert");
7
+ const types_1 = require("seyfert/lib/types");
7
8
  const common_1 = require("seyfert/lib/common");
9
+ const MagmastreamError_1 = require("../structures/MagmastreamError");
10
+ const Enums_1 = require("../structures/Enums");
8
11
  tslib_1.__exportStar(require("../index"), exports);
9
12
  /**
10
13
  * Seyfert wrapper for Magmastream.
@@ -36,6 +39,21 @@ class SeyfertManager extends Manager_1.Manager {
36
39
  constructor(client, options) {
37
40
  super(options);
38
41
  this.client = client;
42
+ this.client
43
+ .getRC()
44
+ .then((rc) => {
45
+ if (!(rc.intents & types_1.GatewayIntentBits.GuildVoiceStates)) {
46
+ throw new MagmastreamError_1.MagmaStreamError({
47
+ code: Enums_1.MagmaStreamErrorCode.INTENT_MISSING,
48
+ message: "[Custom Wrapper] Your Seyfert client must have the GuildVoiceStates intent enabled.",
49
+ });
50
+ }
51
+ })
52
+ .catch((error) => {
53
+ queueMicrotask(() => {
54
+ throw error;
55
+ });
56
+ });
39
57
  }
40
58
  send(packet) {
41
59
  if (this.client instanceof seyfert_1.Client) {
@@ -46,7 +64,7 @@ class SeyfertManager extends Manager_1.Manager {
46
64
  }
47
65
  }
48
66
  async resolveUser(user) {
49
- const id = typeof user === "string" ? user : user.id;
67
+ const id = typeof user === "string" ? user : String(user.id);
50
68
  const cached = this.client.cache.users?.get(id);
51
69
  if (cached)
52
70
  return cached;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magmastream",
3
- "version": "2.9.3-dev.14",
3
+ "version": "2.9.3-dev.16",
4
4
  "description": "A user-friendly Lavalink client designed for NodeJS.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -44,7 +44,7 @@
44
44
  "ws": "^8.19.0"
45
45
  },
46
46
  "optionalDependencies": {
47
- "detritus-client": "0.16.x",
47
+ "discordeno": "21.x",
48
48
  "discord.js": "14.x",
49
49
  "eris": "0.18.x",
50
50
  "oceanic.js": "^1.13.0",
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DetritusManager = void 0;
4
- const tslib_1 = require("tslib");
5
- const Manager_1 = require("../structures/Manager");
6
- const detritus_client_1 = require("detritus-client");
7
- tslib_1.__exportStar(require("../index"), exports);
8
- /**
9
- * Detritus wrapper for Magmastream.
10
- */
11
- class DetritusManager extends Manager_1.Manager {
12
- client;
13
- constructor(client, options) {
14
- super(options);
15
- this.client = client;
16
- client.once("ready", () => {
17
- if (!this.options.clientId)
18
- this.options.clientId = client instanceof detritus_client_1.ClusterClient ? client.applicationId : client.clientId;
19
- });
20
- client.on("raw", async (packet) => {
21
- await this.updateVoiceState(packet);
22
- });
23
- }
24
- send(packet) {
25
- const asCluster = this.client;
26
- const asShard = this.client;
27
- if (asShard.guilds)
28
- return asShard.gateway.send(packet.op, packet.d);
29
- if (asCluster.shards) {
30
- const shard = asCluster.shards.find((c) => c.guilds.has(packet.d.guild_id));
31
- if (shard)
32
- shard.gateway.send(packet.op, packet.d);
33
- }
34
- }
35
- async resolveUser(user) {
36
- const id = typeof user === "string" ? user : user.id;
37
- if (this.client instanceof detritus_client_1.ShardClient) {
38
- const cached = this.client.users.get(id);
39
- if (cached)
40
- return { id: cached.id, username: cached.username };
41
- }
42
- else if (this.client instanceof detritus_client_1.ClusterClient) {
43
- for (const [, shard] of this.client.shards) {
44
- const cached = shard.users.get(id);
45
- if (cached)
46
- return { id: cached.id, username: cached.username };
47
- }
48
- }
49
- return typeof user === "string" ? { id: user } : user;
50
- }
51
- }
52
- exports.DetritusManager = DetritusManager;