magmastream 2.9.3-dev.25 → 2.9.3-dev.27
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/config/blockedWords.d.ts +1 -0
- package/dist/index.d.ts +19 -3781
- package/dist/statestorage/JsonQueue.d.ts +173 -0
- package/dist/statestorage/JsonQueue.js +5 -2
- package/dist/statestorage/MemoryQueue.d.ts +154 -0
- package/dist/statestorage/MemoryQueue.js +6 -2
- package/dist/statestorage/RedisQueue.d.ts +178 -0
- package/dist/structures/Enums.d.ts +310 -0
- package/dist/structures/Filters.d.ts +352 -0
- package/dist/structures/MagmastreamError.d.ts +14 -0
- package/dist/structures/Manager.d.ts +259 -0
- package/dist/structures/Manager.js +198 -368
- package/dist/structures/Node.d.ts +390 -0
- package/dist/structures/Player.d.ts +347 -0
- package/dist/structures/Player.js +1 -1
- package/dist/structures/Plugin.d.ts +23 -0
- package/dist/structures/Rest.d.ts +93 -0
- package/dist/structures/Types.d.ts +1315 -0
- package/dist/structures/Utils.d.ts +169 -0
- package/dist/structures/Utils.js +17 -1
- package/dist/utils/filtersEqualizers.d.ts +16 -0
- package/dist/utils/managerCheck.d.ts +7 -0
- package/dist/utils/nodeCheck.d.ts +7 -0
- package/dist/utils/playerCheck.d.ts +7 -0
- package/dist/wrappers/discord.js.d.ts +15 -0
- package/dist/wrappers/discordeno.d.ts +19 -0
- package/dist/wrappers/eris.d.ts +15 -0
- package/dist/wrappers/oceanic.d.ts +15 -0
- package/dist/wrappers/seyfert.d.ts +37 -0
- package/package.json +2 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { AutoPlayPlatform, TrackPartial } from "./Enums";
|
|
2
|
+
import { Manager } from "./Manager";
|
|
3
|
+
import { AnyUser, ErrorOrEmptySearchResult, Extendable, LavalinkResponse, SearchResult, SerializedPlayerState, Track, TrackData } from "./Types";
|
|
4
|
+
import { Player } from "./Player";
|
|
5
|
+
export declare abstract class TrackUtils {
|
|
6
|
+
static trackPartial: TrackPartial[] | null;
|
|
7
|
+
private static manager;
|
|
8
|
+
/**
|
|
9
|
+
* Initializes the TrackUtils class with the given manager.
|
|
10
|
+
* @param manager The manager instance to use.
|
|
11
|
+
* @hidden
|
|
12
|
+
*/
|
|
13
|
+
static init(manager: Manager): void;
|
|
14
|
+
/**
|
|
15
|
+
* Sets the partial properties for the Track class. If a Track has some of its properties removed by the partial,
|
|
16
|
+
* it will be considered a partial Track.
|
|
17
|
+
* @param {TrackPartial} partial The array of string property names to remove from the Track class.
|
|
18
|
+
*/
|
|
19
|
+
static setTrackPartial(partial: TrackPartial[]): void;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the provided argument is a valid Track.
|
|
22
|
+
* @param value The value to check.
|
|
23
|
+
* @returns {boolean} Whether the provided argument is a valid Track.
|
|
24
|
+
*/
|
|
25
|
+
static isTrack(track: unknown): track is Track;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the provided argument is a valid Track array.
|
|
28
|
+
* @param value The value to check.
|
|
29
|
+
* @returns {boolean} Whether the provided argument is a valid Track array.
|
|
30
|
+
*/
|
|
31
|
+
static isTrackArray(value: unknown): value is Track[];
|
|
32
|
+
/**
|
|
33
|
+
* Checks if the provided argument is a valid Track or Track array.
|
|
34
|
+
* @param value The value to check.
|
|
35
|
+
* @returns {boolean} Whether the provided argument is a valid Track or Track array.
|
|
36
|
+
*/
|
|
37
|
+
static validate(value: unknown): value is Track | Track[];
|
|
38
|
+
/**
|
|
39
|
+
* Builds a Track from the raw data from Lavalink and a optional requester.
|
|
40
|
+
* @param data The raw data from Lavalink to build the Track from.
|
|
41
|
+
* @param requester The user who requested the track, if any.
|
|
42
|
+
* @param isAutoPlay Whether the track is autoplayed. Defaults to false.
|
|
43
|
+
* @returns The built Track.
|
|
44
|
+
*/
|
|
45
|
+
static build<T = AnyUser>(data: TrackData, requester?: T, isAutoplay?: boolean): Track;
|
|
46
|
+
/**
|
|
47
|
+
* Validates a search result.
|
|
48
|
+
* @param result The search result to validate.
|
|
49
|
+
* @returns Whether the search result is valid.
|
|
50
|
+
*/
|
|
51
|
+
static isErrorOrEmptySearchResult(result: SearchResult): result is ErrorOrEmptySearchResult;
|
|
52
|
+
/**
|
|
53
|
+
* Revives a track.
|
|
54
|
+
* @param track The track to revive.
|
|
55
|
+
* @returns The revived track.
|
|
56
|
+
*/
|
|
57
|
+
static revive(track: Track): Track;
|
|
58
|
+
}
|
|
59
|
+
export declare abstract class AutoPlayUtils {
|
|
60
|
+
private static manager;
|
|
61
|
+
/**
|
|
62
|
+
* Initializes the AutoPlayUtils class with the given manager.
|
|
63
|
+
* @param manager The manager instance to use.
|
|
64
|
+
* @hidden
|
|
65
|
+
*/
|
|
66
|
+
static init(manager: Manager): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Gets recommended tracks for the given track.
|
|
69
|
+
* @param track The track to get recommended tracks for.
|
|
70
|
+
* @returns An array of recommended tracks.
|
|
71
|
+
*/
|
|
72
|
+
static getRecommendedTracks(track: Track): Promise<Track[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Gets recommended tracks from Last.fm for the given track.
|
|
75
|
+
* @param track The track to get recommended tracks for.
|
|
76
|
+
* @param apiKey The API key for Last.fm.
|
|
77
|
+
* @returns An array of recommended tracks.
|
|
78
|
+
*/
|
|
79
|
+
static getRecommendedTracksFromLastFm(track: Track, apiKey: string): Promise<Track[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Gets recommended tracks from the given source.
|
|
82
|
+
* @param track The track to get recommended tracks for.
|
|
83
|
+
* @param platform The source to get recommended tracks from.
|
|
84
|
+
* @returns An array of recommended tracks.
|
|
85
|
+
*/
|
|
86
|
+
static getRecommendedTracksFromSource(track: Track, platform: AutoPlayPlatform): Promise<Track[]>;
|
|
87
|
+
/**
|
|
88
|
+
* Searches for a track using the manager and returns resolved tracks.
|
|
89
|
+
* @param query The search query (artist - title).
|
|
90
|
+
* @param requester The requester who initiated the search.
|
|
91
|
+
* @returns An array of resolved tracks, or an empty array if not found or error occurred.
|
|
92
|
+
*/
|
|
93
|
+
private static resolveTracksFromQuery;
|
|
94
|
+
/**
|
|
95
|
+
* Resolves the first available track from a search query using the specified source.
|
|
96
|
+
* Useful for normalizing tracks that lack platform-specific metadata or URIs.
|
|
97
|
+
*
|
|
98
|
+
* @param query - The search query string (usually "Artist - Title").
|
|
99
|
+
* @param source - The search platform to use (e.g., Spotify, Deezer, YouTube).
|
|
100
|
+
* @param requester - The requester object, used for context or attribution.
|
|
101
|
+
* @returns A single resolved {@link Track} object if found, or `null` if the search fails or returns no results.
|
|
102
|
+
*/
|
|
103
|
+
private static resolveFirstTrackFromQuery;
|
|
104
|
+
private static isPlaylistRawData;
|
|
105
|
+
private static isTrackData;
|
|
106
|
+
private static isTrackDataArray;
|
|
107
|
+
static buildTracksFromResponse<T>(recommendedResult: LavalinkResponse, requester?: T): Track[];
|
|
108
|
+
}
|
|
109
|
+
export declare abstract class PlayerUtils {
|
|
110
|
+
private static manager;
|
|
111
|
+
/**
|
|
112
|
+
* Initializes the PlayerUtils class with the given manager.
|
|
113
|
+
* @param manager The manager instance to use.
|
|
114
|
+
* @hidden
|
|
115
|
+
*/
|
|
116
|
+
static init(manager: Manager): void;
|
|
117
|
+
/**
|
|
118
|
+
* Serializes a Player instance to avoid circular references.
|
|
119
|
+
* @param player The Player instance to serialize
|
|
120
|
+
* @returns The serialized Player instance
|
|
121
|
+
*/
|
|
122
|
+
static serializePlayer(player: Player): Promise<SerializedPlayerState> | null;
|
|
123
|
+
/**
|
|
124
|
+
* Gets the base directory for player data.
|
|
125
|
+
*/
|
|
126
|
+
static getPlayersBaseDir(): string;
|
|
127
|
+
/**
|
|
128
|
+
* Gets the path to the player's directory.
|
|
129
|
+
*/
|
|
130
|
+
static getGuildDir(guildId: string): string;
|
|
131
|
+
/**
|
|
132
|
+
* Gets the path to the player's state file.
|
|
133
|
+
*/
|
|
134
|
+
static getPlayerStatePath(guildId: string): string;
|
|
135
|
+
/**
|
|
136
|
+
* Gets the path to the player's current track file.
|
|
137
|
+
*/
|
|
138
|
+
static getPlayerCurrentPath(guildId: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Gets the path to the player's queue file.
|
|
141
|
+
*/
|
|
142
|
+
static getPlayerQueuePath(guildId: string): string;
|
|
143
|
+
/**
|
|
144
|
+
* Gets the path to the player's previous tracks file.
|
|
145
|
+
*/
|
|
146
|
+
static getPlayerPreviousPath(guildId: string): string;
|
|
147
|
+
/**
|
|
148
|
+
* Gets the Redis key for player storage.
|
|
149
|
+
*/
|
|
150
|
+
static getRedisKey(): string;
|
|
151
|
+
}
|
|
152
|
+
/** Gets or extends structures to extend the built in, or already extended, classes to add more functionality. */
|
|
153
|
+
export declare abstract class Structure {
|
|
154
|
+
/**
|
|
155
|
+
* Extends a class.
|
|
156
|
+
* @param name
|
|
157
|
+
* @param extender
|
|
158
|
+
*/
|
|
159
|
+
static extend<K extends keyof Extendable, T extends Extendable[K]>(name: K, extender: (target: Extendable[K]) => T): T;
|
|
160
|
+
/**
|
|
161
|
+
* Get a structure from available structures by name.
|
|
162
|
+
* @param name
|
|
163
|
+
*/
|
|
164
|
+
static get<K extends keyof Extendable>(name: K): Extendable[K];
|
|
165
|
+
}
|
|
166
|
+
export declare abstract class JSONUtils {
|
|
167
|
+
static safe<T>(obj: T, space?: number): string;
|
|
168
|
+
static serializeTrack(track: Track): string;
|
|
169
|
+
}
|
package/dist/structures/Utils.js
CHANGED
|
@@ -653,10 +653,13 @@ class PlayerUtils {
|
|
|
653
653
|
try {
|
|
654
654
|
const [current, tracks, previous] = await Promise.all([player.queue.getCurrent(), player.queue.getTracks(), player.queue.getPrevious()]);
|
|
655
655
|
const serializeTrack = (track) => {
|
|
656
|
+
if (!track || !track.identifier)
|
|
657
|
+
return null;
|
|
656
658
|
try {
|
|
657
659
|
return {
|
|
658
660
|
...track,
|
|
659
661
|
requester: track.requester ? { id: track.requester.id, username: track.requester.username } : null,
|
|
662
|
+
displayThumbnail: undefined,
|
|
660
663
|
};
|
|
661
664
|
}
|
|
662
665
|
catch {
|
|
@@ -681,7 +684,11 @@ class PlayerUtils {
|
|
|
681
684
|
safeNode = null;
|
|
682
685
|
}
|
|
683
686
|
}
|
|
687
|
+
const serializableData = player.getSerializableData();
|
|
688
|
+
const nowPlayingMessage = serializableData.nowPlayingMessage;
|
|
689
|
+
delete serializableData.nowPlayingMessage;
|
|
684
690
|
const snapshot = {
|
|
691
|
+
clusterId: player.clusterId,
|
|
685
692
|
options: player.options,
|
|
686
693
|
voiceState: player.voiceState,
|
|
687
694
|
guildId: player.guildId,
|
|
@@ -714,7 +721,16 @@ class PlayerUtils {
|
|
|
714
721
|
filterStatus: { ...player.filters.filtersStatus },
|
|
715
722
|
}
|
|
716
723
|
: null,
|
|
717
|
-
data:
|
|
724
|
+
data: {
|
|
725
|
+
...safeSerialize(serializableData),
|
|
726
|
+
nowPlayingMessage: nowPlayingMessage
|
|
727
|
+
? {
|
|
728
|
+
id: String(nowPlayingMessage.id),
|
|
729
|
+
channelId: nowPlayingMessage.channelId,
|
|
730
|
+
guildId: nowPlayingMessage.guildId,
|
|
731
|
+
}
|
|
732
|
+
: null,
|
|
733
|
+
},
|
|
718
734
|
};
|
|
719
735
|
// Sanity check
|
|
720
736
|
JSON.stringify(snapshot);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Represents an equalizer band. */
|
|
2
|
+
export interface Band {
|
|
3
|
+
/** The index of the equalizer band (0-12). */
|
|
4
|
+
band: number;
|
|
5
|
+
/** The gain value of the equalizer band (in decibels). */
|
|
6
|
+
gain: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const bassBoostEqualizer: Band[];
|
|
9
|
+
export declare const softEqualizer: Band[];
|
|
10
|
+
export declare const tvEqualizer: Band[];
|
|
11
|
+
export declare const trebleBassEqualizer: Band[];
|
|
12
|
+
export declare const vaporwaveEqualizer: Band[];
|
|
13
|
+
export declare const popEqualizer: Band[];
|
|
14
|
+
export declare const electronicEqualizer: Band[];
|
|
15
|
+
export declare const radioEqualizer: Band[];
|
|
16
|
+
export declare const demonEqualizer: Band[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ManagerOptions } from "../structures/Types";
|
|
2
|
+
/**
|
|
3
|
+
* Validates the provided ManagerOptions object.
|
|
4
|
+
* @param options - The options to validate.
|
|
5
|
+
* @throws {MagmaStreamError} Throws if any required option is missing or invalid.
|
|
6
|
+
*/
|
|
7
|
+
export default function managerCheck(options: ManagerOptions): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NodeOptions } from "../structures/Types";
|
|
2
|
+
/**
|
|
3
|
+
* Validates the provided NodeOptions object.
|
|
4
|
+
* @param options - The options to validate.
|
|
5
|
+
* @throws {MagmaStreamError} Throws if any required option is missing or invalid.
|
|
6
|
+
*/
|
|
7
|
+
export default function nodeCheck(options: NodeOptions): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PlayerOptions } from "../structures/Types";
|
|
2
|
+
/**
|
|
3
|
+
* Validates the provided PlayerOptions object.
|
|
4
|
+
* @param options - The options to validate.
|
|
5
|
+
* @throws {MagmaStreamError} Throws if any required option is missing or invalid.
|
|
6
|
+
*/
|
|
7
|
+
export default function playerCheck(options: PlayerOptions): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Manager as BaseManager } from "../structures/Manager";
|
|
2
|
+
import type { GatewayVoiceStateUpdate } from "discord-api-types/v10";
|
|
3
|
+
import { Client, Guild, User } from "discord.js";
|
|
4
|
+
import { AnyUser, ManagerOptions } from "../structures/Types";
|
|
5
|
+
export * from "../index";
|
|
6
|
+
/**
|
|
7
|
+
* Discord.js wrapper for Magmastream.
|
|
8
|
+
*/
|
|
9
|
+
export declare class DiscordJSManager extends BaseManager {
|
|
10
|
+
readonly client: Client;
|
|
11
|
+
constructor(client: Client, options?: ManagerOptions);
|
|
12
|
+
protected send(packet: GatewayVoiceStateUpdate): void;
|
|
13
|
+
resolveUser(user: AnyUser | string): Promise<User | AnyUser>;
|
|
14
|
+
resolveGuild(guildId: string): Guild | null;
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GatewayVoiceStateUpdate } from "discord-api-types/v10";
|
|
2
|
+
import { Manager as BaseManager } from "../structures/Manager";
|
|
3
|
+
import { Bot, User } from "@discordeno/bot";
|
|
4
|
+
import { AnyGuild, AnyUser, ManagerOptions } from "../structures/Types";
|
|
5
|
+
export * from "../index";
|
|
6
|
+
/**
|
|
7
|
+
* Discordeno wrapper for Magmastream.
|
|
8
|
+
*/
|
|
9
|
+
export declare class DiscordenoManager extends BaseManager {
|
|
10
|
+
readonly client: Bot;
|
|
11
|
+
constructor(client: Bot, options?: ManagerOptions);
|
|
12
|
+
protected send(packet: GatewayVoiceStateUpdate): void;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve a user by ID or partial info.
|
|
15
|
+
* Uses user-provided cache getter if available, otherwise falls back to minimal info.
|
|
16
|
+
*/
|
|
17
|
+
resolveUser(user: AnyUser | string): Promise<User | AnyUser>;
|
|
18
|
+
resolveGuild(guildId: string): AnyGuild;
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GatewayVoiceStateUpdate } from "discord-api-types/v10";
|
|
2
|
+
import { Manager as BaseManager } from "../structures/Manager";
|
|
3
|
+
import type { Client, Guild, User } from "eris";
|
|
4
|
+
import { AnyUser, ManagerOptions } from "../structures/Types";
|
|
5
|
+
export * from "../index";
|
|
6
|
+
/**
|
|
7
|
+
* Eris wrapper for Magmastream.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ErisManager extends BaseManager {
|
|
10
|
+
readonly client: Client;
|
|
11
|
+
constructor(client: Client, options?: ManagerOptions);
|
|
12
|
+
protected send(packet: GatewayVoiceStateUpdate): void;
|
|
13
|
+
resolveUser(user: AnyUser | string): Promise<User | AnyUser>;
|
|
14
|
+
resolveGuild(guildId: string): Guild;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GatewayVoiceStateUpdate } from "discord-api-types/v10";
|
|
2
|
+
import { Manager as BaseManager } from "../structures/Manager";
|
|
3
|
+
import { AnyUser, ManagerOptions } from "../structures/Types";
|
|
4
|
+
import { Client, Guild, User } from "oceanic.js";
|
|
5
|
+
export * from "../index";
|
|
6
|
+
/**
|
|
7
|
+
* Oceanic wrapper for Magmastream.
|
|
8
|
+
*/
|
|
9
|
+
export declare class OceanicManager extends BaseManager {
|
|
10
|
+
readonly client: Client;
|
|
11
|
+
constructor(client: Client, options?: ManagerOptions);
|
|
12
|
+
protected send(packet: GatewayVoiceStateUpdate): void;
|
|
13
|
+
resolveUser(user: AnyUser | string): Promise<User | AnyUser>;
|
|
14
|
+
resolveGuild(guildId: string): Guild;
|
|
15
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Manager as BaseManager } from "../structures/Manager";
|
|
2
|
+
import { type GatewayVoiceStateUpdate } from "discord-api-types/v10";
|
|
3
|
+
import { Client, Guild, User, WorkerClient } from "seyfert";
|
|
4
|
+
import { AnyUser, ManagerOptions } from "../structures/Types";
|
|
5
|
+
export * from "../index";
|
|
6
|
+
/**
|
|
7
|
+
* Seyfert wrapper for Magmastream.
|
|
8
|
+
*
|
|
9
|
+
* @note This wrapper does require the manual implementation of the "raw" and "ready" events, to call the `updateVoiceState` and `init` methods respectively.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const client = new Client();
|
|
14
|
+
* const manager = new SeyfertManager(client, options);
|
|
15
|
+
*
|
|
16
|
+
* client.events.values.RAW = {
|
|
17
|
+
* data: { name: "raw" },
|
|
18
|
+
* run: async (data) => {
|
|
19
|
+
* await manager.updateVoiceState(data);
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* client.events.values.READY = {
|
|
24
|
+
* data: { name: "ready" },
|
|
25
|
+
* run: async (user, client) => {
|
|
26
|
+
* await manager.init({ clientId: client.botId });
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class SeyfertManager extends BaseManager {
|
|
32
|
+
readonly client: Client | WorkerClient;
|
|
33
|
+
constructor(client: Client | WorkerClient, options?: ManagerOptions);
|
|
34
|
+
protected send(packet: GatewayVoiceStateUpdate): void;
|
|
35
|
+
resolveUser(user: AnyUser | string): Promise<User | AnyUser>;
|
|
36
|
+
resolveGuild(guildId: string): Guild<"cached">;
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magmastream",
|
|
3
|
-
"version": "2.9.3-dev.
|
|
3
|
+
"version": "2.9.3-dev.27",
|
|
4
4
|
"description": "A user-friendly Lavalink client designed for NodeJS.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
+
"prepare": "npm run build",
|
|
11
12
|
"build": "tsc",
|
|
12
13
|
"types": "rtb --dist dist",
|
|
13
14
|
"format": "prettier --write .",
|