magmastream 2.9.3-dev.20 → 2.9.3-dev.21
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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Collection } from '@discordjs/collection';
|
|
2
2
|
import { GatewayVoiceStateUpdate } from 'discord-api-types/v10';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
|
-
import { User, ClientUser, Message, Client } from 'discord.js';
|
|
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, Bot } from '@discordeno/bot';
|
|
7
|
-
import { User as User$3, Message as Message$3, Client as Client$1 } from 'eris';
|
|
8
|
-
import { User as User$4, ClientUser as ClientUser$1, Message as Message$4, Client as Client$3, WorkerClient } from 'seyfert';
|
|
4
|
+
import { User, ClientUser, Guild, Message, Client } from 'discord.js';
|
|
5
|
+
import { User as User$1, Guild as Guild$1, Message as Message$1, Client as Client$2 } from 'oceanic.js';
|
|
6
|
+
import { User as User$2, Guild as Guild$2, Message as Message$2, Bot } from '@discordeno/bot';
|
|
7
|
+
import { User as User$3, Guild as Guild$3, Message as Message$3, Client as Client$1 } from 'eris';
|
|
8
|
+
import { User as User$4, ClientUser as ClientUser$1, Guild as Guild$4, 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
11
|
|
|
@@ -925,8 +925,18 @@ interface ManagerOptions {
|
|
|
925
925
|
* Optional user cache getter.
|
|
926
926
|
* When resolving a user from a partial ID, this function will be called first.
|
|
927
927
|
* Should return the full user object if cached, or undefined if not.
|
|
928
|
+
* @param id The ID of the user to get.
|
|
929
|
+
* @returns The user object if cached, or undefined if not.
|
|
928
930
|
*/
|
|
929
931
|
getUser?: (id: string) => AnyUser | undefined;
|
|
932
|
+
/**
|
|
933
|
+
* Optional guild cache getter.
|
|
934
|
+
* When resolving a guild from a partial ID, this function will be called first.
|
|
935
|
+
* Should return the full guild object if cached, or undefined if not.
|
|
936
|
+
* @param id The ID of the guild to get.
|
|
937
|
+
* @returns The guild object if cached, or undefined if not.
|
|
938
|
+
*/
|
|
939
|
+
getGuild?: (id: string) => AnyGuild | undefined;
|
|
930
940
|
}
|
|
931
941
|
/**
|
|
932
942
|
* State Storage Options
|
|
@@ -1013,6 +1023,10 @@ interface PortableMessage {
|
|
|
1013
1023
|
* Any message
|
|
1014
1024
|
*/
|
|
1015
1025
|
type AnyMessage = PortableMessage | Message | Message$1 | Message$2 | Message$3 | Message$4;
|
|
1026
|
+
/**
|
|
1027
|
+
* Any guild
|
|
1028
|
+
*/
|
|
1029
|
+
type AnyGuild = Guild | Guild$1 | Guild$2 | Guild$3 | Guild$4<"cached">;
|
|
1016
1030
|
/**
|
|
1017
1031
|
* Discord Packet
|
|
1018
1032
|
*/
|
|
@@ -2913,6 +2927,7 @@ declare class Manager extends EventEmitter {
|
|
|
2913
2927
|
redis?: Redis;
|
|
2914
2928
|
private _send;
|
|
2915
2929
|
private _getUser?;
|
|
2930
|
+
private _getGuild?;
|
|
2916
2931
|
private loadedPlugins;
|
|
2917
2932
|
/**
|
|
2918
2933
|
* Initiates the Manager class.
|
|
@@ -3142,6 +3157,11 @@ declare class Manager extends EventEmitter {
|
|
|
3142
3157
|
* Can be overridden by wrapper managers to return wrapper-specific User classes.
|
|
3143
3158
|
*/
|
|
3144
3159
|
resolveUser(user: AnyUser | string): Promise<AnyUser>;
|
|
3160
|
+
/**
|
|
3161
|
+
* Resolves a Guild ID to a real guild object.
|
|
3162
|
+
* Can be overridden by wrapper managers to return wrapper-specific Guild classes.
|
|
3163
|
+
*/
|
|
3164
|
+
resolveGuild(guildId: string): AnyGuild;
|
|
3145
3165
|
}
|
|
3146
3166
|
|
|
3147
3167
|
declare class Filters {
|
|
@@ -3693,6 +3713,7 @@ declare class DiscordJSManager extends Manager {
|
|
|
3693
3713
|
constructor(client: Client, options?: ManagerOptions);
|
|
3694
3714
|
protected send(packet: GatewayVoiceStateUpdate): void;
|
|
3695
3715
|
resolveUser(user: AnyUser | string): Promise<User | AnyUser>;
|
|
3716
|
+
resolveGuild(guildId: string): Guild | null;
|
|
3696
3717
|
}
|
|
3697
3718
|
|
|
3698
3719
|
/**
|
|
@@ -3703,6 +3724,7 @@ declare class ErisManager extends Manager {
|
|
|
3703
3724
|
constructor(client: Client$1, options?: ManagerOptions);
|
|
3704
3725
|
protected send(packet: GatewayVoiceStateUpdate): void;
|
|
3705
3726
|
resolveUser(user: AnyUser | string): Promise<User$3 | AnyUser>;
|
|
3727
|
+
resolveGuild(guildId: string): Guild$3;
|
|
3706
3728
|
}
|
|
3707
3729
|
|
|
3708
3730
|
/**
|
|
@@ -3713,6 +3735,7 @@ declare class OceanicManager extends Manager {
|
|
|
3713
3735
|
constructor(client: Client$2, options?: ManagerOptions);
|
|
3714
3736
|
protected send(packet: GatewayVoiceStateUpdate): void;
|
|
3715
3737
|
resolveUser(user: AnyUser | string): Promise<User$1 | AnyUser>;
|
|
3738
|
+
resolveGuild(guildId: string): Guild$1;
|
|
3716
3739
|
}
|
|
3717
3740
|
|
|
3718
3741
|
/**
|
|
@@ -3745,7 +3768,8 @@ declare class SeyfertManager extends Manager {
|
|
|
3745
3768
|
constructor(client: Client$3 | WorkerClient, options?: ManagerOptions);
|
|
3746
3769
|
protected send(packet: GatewayVoiceStateUpdate): void;
|
|
3747
3770
|
resolveUser(user: AnyUser | string): Promise<User$4 | AnyUser>;
|
|
3771
|
+
resolveGuild(guildId: string): Guild$4<"cached">;
|
|
3748
3772
|
}
|
|
3749
3773
|
|
|
3750
3774
|
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 };
|
|
3775
|
+
export type { AlbumSearchResult, AnyGuild, 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 };
|
|
@@ -29,6 +29,7 @@ class Manager extends events_1.EventEmitter {
|
|
|
29
29
|
redis;
|
|
30
30
|
_send;
|
|
31
31
|
_getUser;
|
|
32
|
+
_getGuild;
|
|
32
33
|
loadedPlugins = new Set();
|
|
33
34
|
/**
|
|
34
35
|
* Initiates the Manager class.
|
|
@@ -64,6 +65,8 @@ class Manager extends events_1.EventEmitter {
|
|
|
64
65
|
this._send = options.send;
|
|
65
66
|
if (options.getUser && !this._getUser)
|
|
66
67
|
this._getUser = options.getUser;
|
|
68
|
+
if (options.getGuild && !this._getGuild)
|
|
69
|
+
this._getGuild = options.getGuild;
|
|
67
70
|
this.options = {
|
|
68
71
|
...options,
|
|
69
72
|
enabledPlugins: options.enabledPlugins ?? [],
|
|
@@ -533,10 +536,11 @@ class Manager extends events_1.EventEmitter {
|
|
|
533
536
|
await promises_1.default.access(stateFilePath);
|
|
534
537
|
const rawData = await promises_1.default.readFile(stateFilePath, "utf-8");
|
|
535
538
|
const state = JSON.parse(rawData);
|
|
536
|
-
if (state.clusterId !== this.options.clusterId)
|
|
537
|
-
continue;
|
|
538
539
|
if (!state.guildId || state.node?.options?.identifier !== nodeId)
|
|
539
540
|
continue;
|
|
541
|
+
const hasGuild = this.resolveGuild(state.guildId);
|
|
542
|
+
if (!hasGuild)
|
|
543
|
+
continue;
|
|
540
544
|
const lavaPlayer = await node.rest.getPlayer(state.guildId);
|
|
541
545
|
if (!lavaPlayer) {
|
|
542
546
|
await this.destroy(state.guildId);
|
|
@@ -686,31 +690,18 @@ class Manager extends events_1.EventEmitter {
|
|
|
686
690
|
filterActions[filter](true);
|
|
687
691
|
}
|
|
688
692
|
}
|
|
689
|
-
|
|
690
|
-
await this.sleep(1000);
|
|
691
|
-
}
|
|
692
|
-
catch (error) {
|
|
693
|
-
this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Error processing player state for guild ${guildId}: ${error}`);
|
|
694
|
-
continue;
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
// Cleanup old player state files from guild directories whose nodeId matches
|
|
698
|
-
for (const dirent of guildDirs) {
|
|
699
|
-
if (!dirent.isDirectory())
|
|
700
|
-
continue;
|
|
701
|
-
const guildId = dirent.name;
|
|
702
|
-
const stateFilePath = Utils_1.PlayerUtils.getPlayerStatePath(guildId);
|
|
703
|
-
try {
|
|
704
|
-
await promises_1.default.access(stateFilePath);
|
|
705
|
-
const data = await promises_1.default.readFile(stateFilePath, "utf-8");
|
|
706
|
-
const state = JSON.parse(data);
|
|
707
|
-
if (state && typeof state === "object" && state.node?.options?.identifier === nodeId) {
|
|
693
|
+
try {
|
|
708
694
|
await promises_1.default.rm(Utils_1.PlayerUtils.getPlayerStatePath(guildId), { force: true });
|
|
709
695
|
this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Deleted player state folder for guild ${guildId}`);
|
|
710
696
|
}
|
|
697
|
+
catch (error) {
|
|
698
|
+
this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Error deleting player state for guild ${guildId}: ${error}`);
|
|
699
|
+
}
|
|
700
|
+
this.emit(Enums_1.ManagerEventTypes.PlayerRestored, player, node);
|
|
701
|
+
await this.sleep(1000);
|
|
711
702
|
}
|
|
712
703
|
catch (error) {
|
|
713
|
-
this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Error
|
|
704
|
+
this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Error processing player state for guild ${guildId}: ${error}`);
|
|
714
705
|
continue;
|
|
715
706
|
}
|
|
716
707
|
}
|
|
@@ -732,11 +723,14 @@ class Manager extends events_1.EventEmitter {
|
|
|
732
723
|
if (!data)
|
|
733
724
|
continue;
|
|
734
725
|
const state = JSON.parse(data);
|
|
735
|
-
if (!state || typeof state !== "object"
|
|
726
|
+
if (!state || typeof state !== "object")
|
|
736
727
|
continue;
|
|
737
728
|
const guildId = key.split(":").pop();
|
|
738
729
|
if (!guildId || state.node.options.identifier !== nodeId)
|
|
739
730
|
continue;
|
|
731
|
+
const hasGuild = this.resolveGuild(guildId);
|
|
732
|
+
if (!hasGuild)
|
|
733
|
+
continue;
|
|
740
734
|
const lavaPlayer = await node.rest.getPlayer(state.guildId);
|
|
741
735
|
if (!lavaPlayer) {
|
|
742
736
|
await this.destroy(guildId);
|
|
@@ -1468,5 +1462,14 @@ class Manager extends events_1.EventEmitter {
|
|
|
1468
1462
|
return { id: user }; // fallback by ID only
|
|
1469
1463
|
return user; // default: just return the portable user
|
|
1470
1464
|
}
|
|
1465
|
+
/**
|
|
1466
|
+
* Resolves a Guild ID to a real guild object.
|
|
1467
|
+
* Can be overridden by wrapper managers to return wrapper-specific Guild classes.
|
|
1468
|
+
*/
|
|
1469
|
+
resolveGuild(guildId) {
|
|
1470
|
+
if (!guildId)
|
|
1471
|
+
return null;
|
|
1472
|
+
return this._getGuild?.(guildId);
|
|
1473
|
+
}
|
|
1471
1474
|
}
|
|
1472
1475
|
exports.Manager = Manager;
|
package/dist/structures/Utils.js
CHANGED
|
@@ -737,7 +737,7 @@ class PlayerUtils {
|
|
|
737
737
|
* Gets the base directory for player data.
|
|
738
738
|
*/
|
|
739
739
|
static getPlayersBaseDir() {
|
|
740
|
-
return path_1.default.join(process.cwd(), "magmastream", "sessionData", "
|
|
740
|
+
return path_1.default.join(process.cwd(), "magmastream", "sessionData", "players");
|
|
741
741
|
}
|
|
742
742
|
/**
|
|
743
743
|
* Gets the path to the player's directory.
|
|
@@ -777,8 +777,7 @@ class PlayerUtils {
|
|
|
777
777
|
// Default prefix
|
|
778
778
|
let prefix = (cfg.prefix ?? "magmastream:").trim();
|
|
779
779
|
prefix = prefix.replace(/:+$/g, "") + ":";
|
|
780
|
-
|
|
781
|
-
return `${prefix}cluster:${clusterId}:`;
|
|
780
|
+
return prefix;
|
|
782
781
|
}
|
|
783
782
|
}
|
|
784
783
|
exports.PlayerUtils = PlayerUtils;
|
|
@@ -60,5 +60,11 @@ class DiscordJSManager extends Manager_1.Manager {
|
|
|
60
60
|
return { id, username: typeof user === "string" ? undefined : user.username };
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
resolveGuild(guildId) {
|
|
64
|
+
const cached = this.client.guilds.cache.get(guildId);
|
|
65
|
+
if (cached)
|
|
66
|
+
return cached;
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
63
69
|
}
|
|
64
70
|
exports.DiscordJSManager = DiscordJSManager;
|
package/dist/wrappers/eris.js
CHANGED
|
@@ -46,5 +46,11 @@ class ErisManager extends Manager_1.Manager {
|
|
|
46
46
|
username: typeof user === "string" ? undefined : user.username,
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
+
resolveGuild(guildId) {
|
|
50
|
+
const cached = this.client.guilds.get(guildId);
|
|
51
|
+
if (cached)
|
|
52
|
+
return cached;
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
49
55
|
}
|
|
50
56
|
exports.ErisManager = ErisManager;
|
package/dist/wrappers/oceanic.js
CHANGED
|
@@ -47,5 +47,11 @@ class OceanicManager extends Manager_1.Manager {
|
|
|
47
47
|
username: typeof user === "string" ? undefined : user.username,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
+
resolveGuild(guildId) {
|
|
51
|
+
const cached = this.client.guilds.get(guildId);
|
|
52
|
+
if (cached)
|
|
53
|
+
return cached;
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
50
56
|
}
|
|
51
57
|
exports.OceanicManager = OceanicManager;
|
package/dist/wrappers/seyfert.js
CHANGED
|
@@ -75,5 +75,11 @@ class SeyfertManager extends Manager_1.Manager {
|
|
|
75
75
|
return { id, username: typeof user === "string" ? undefined : user.username };
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
resolveGuild(guildId) {
|
|
79
|
+
const cached = this.client.cache.guilds?.get(guildId);
|
|
80
|
+
if (cached)
|
|
81
|
+
return cached;
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
78
84
|
}
|
|
79
85
|
exports.SeyfertManager = SeyfertManager;
|