for-modules 1.0.0
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/LICENSE +21 -0
- package/NOTICE.txt +12 -0
- package/README.md +1 -0
- package/babel.config.json +6 -0
- package/dist/Structures/Filters.d.ts +109 -0
- package/dist/Structures/Filters.js +296 -0
- package/dist/Structures/Manager.d.ts +192 -0
- package/dist/Structures/Manager.js +580 -0
- package/dist/Structures/Node.d.ts +140 -0
- package/dist/Structures/Node.js +588 -0
- package/dist/Structures/Player.d.ts +250 -0
- package/dist/Structures/Player.js +750 -0
- package/dist/Structures/Queue.d.ts +38 -0
- package/dist/Structures/Queue.js +180 -0
- package/dist/Structures/Rest.d.ts +60 -0
- package/dist/Structures/Rest.js +246 -0
- package/dist/Structures/Utils.d.ts +174 -0
- package/dist/Structures/Utils.js +318 -0
- package/dist/Utils/FiltersEqualizers.d.ts +12 -0
- package/dist/Utils/FiltersEqualizers.js +227 -0
- package/dist/Utils/ManagerCheck.d.ts +2 -0
- package/dist/Utils/ManagerCheck.js +75 -0
- package/dist/Utils/NodeCheck.d.ts +2 -0
- package/dist/Utils/NodeCheck.js +54 -0
- package/dist/Utils/PlayerCheck.d.ts +2 -0
- package/dist/Utils/PlayerCheck.js +38 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +127 -0
- package/eslint.config.d.ts +2 -0
- package/eslint.config.js +12 -0
- package/package.json +51 -0
- package/renovate.json +6 -0
- package/tsconfig.json +25 -0
@@ -0,0 +1,192 @@
|
|
1
|
+
import { LoadType, Plugin, TrackData, TrackEndEvent, TrackExceptionEvent, TrackStartEvent, TrackStuckEvent, VoicePacket, VoiceServer, WebSocketClosedEvent } from "./Utils";
|
2
|
+
import { Collection } from "@discordjs/collection";
|
3
|
+
import { Node, NodeOptions } from "./Node";
|
4
|
+
import { Player, PlayerOptions, Track, UnresolvedTrack } from "./Player";
|
5
|
+
import { VoiceState } from "..";
|
6
|
+
import { ClientUser, User } from "discord.js";
|
7
|
+
import { TypedEmitter } from "tiny-typed-emitter";
|
8
|
+
/**
|
9
|
+
* The main hub for interacting with Lavalink and using Magmastream,
|
10
|
+
*/
|
11
|
+
export declare class Manager extends TypedEmitter<ManagerEvents> {
|
12
|
+
static readonly DEFAULT_SOURCES: Record<SearchPlatform, string>;
|
13
|
+
/** The map of players. */
|
14
|
+
readonly players: Collection<string, Player>;
|
15
|
+
/** The map of nodes. */
|
16
|
+
readonly nodes: Collection<string, Node>;
|
17
|
+
/** The options that were set. */
|
18
|
+
readonly options: ManagerOptions;
|
19
|
+
private initiated;
|
20
|
+
caches: Collection<string, SearchResult>;
|
21
|
+
/** Returns the nodes that has the least load. */
|
22
|
+
get leastLoadNode(): Collection<string, Node>;
|
23
|
+
/** Returns the nodes that has the least amount of players. */
|
24
|
+
private get leastPlayersNode();
|
25
|
+
/** Returns a node based on priority. */
|
26
|
+
private get priorityNode();
|
27
|
+
/** Returns the node to use. */
|
28
|
+
get useableNodes(): Node;
|
29
|
+
/**
|
30
|
+
* Initiates the Manager class.
|
31
|
+
* @param options
|
32
|
+
*/
|
33
|
+
constructor(options: ManagerOptions);
|
34
|
+
/**
|
35
|
+
* Initiates the Manager.
|
36
|
+
* @param clientId
|
37
|
+
*/
|
38
|
+
init(clientId?: string): this;
|
39
|
+
/**
|
40
|
+
* Searches the enabled sources based off the URL or the `source` property.
|
41
|
+
* @param query
|
42
|
+
* @param requester
|
43
|
+
* @returns The search result.
|
44
|
+
*/
|
45
|
+
search(query: string | SearchQuery, requester?: User | ClientUser): Promise<SearchResult>;
|
46
|
+
/**
|
47
|
+
* Decodes the base64 encoded tracks and returns a TrackData array.
|
48
|
+
* @param tracks
|
49
|
+
*/
|
50
|
+
decodeTracks(tracks: string[]): Promise<TrackData[]>;
|
51
|
+
/**
|
52
|
+
* Decodes the base64 encoded track and returns a TrackData.
|
53
|
+
* @param track
|
54
|
+
*/
|
55
|
+
decodeTrack(track: string): Promise<TrackData>;
|
56
|
+
/**
|
57
|
+
* Creates a player or returns one if it already exists.
|
58
|
+
* @param options
|
59
|
+
*/
|
60
|
+
create(options: PlayerOptions): Player;
|
61
|
+
/**
|
62
|
+
* Returns a player or undefined if it does not exist.
|
63
|
+
* @param guild
|
64
|
+
*/
|
65
|
+
get(guild: string): Player | undefined;
|
66
|
+
/**
|
67
|
+
* Destroys a player if it exists.
|
68
|
+
* @param guild
|
69
|
+
*/
|
70
|
+
destroy(guild: string): void;
|
71
|
+
/**
|
72
|
+
* Creates a node or returns one if it already exists.
|
73
|
+
* @param options
|
74
|
+
*/
|
75
|
+
createNode(options: NodeOptions): Node;
|
76
|
+
/**
|
77
|
+
* Destroys a node if it exists.
|
78
|
+
* @param identifier
|
79
|
+
*/
|
80
|
+
destroyNode(identifier: string): void;
|
81
|
+
/**
|
82
|
+
* Sends voice data to the Lavalink server.
|
83
|
+
* @param data
|
84
|
+
*/
|
85
|
+
updateVoiceState(data: VoicePacket | VoiceServer | VoiceState): Promise<void>;
|
86
|
+
}
|
87
|
+
export interface Payload {
|
88
|
+
/** The OP code */
|
89
|
+
op: number;
|
90
|
+
d: {
|
91
|
+
guild_id: string;
|
92
|
+
channel_id: string | null;
|
93
|
+
self_mute: boolean;
|
94
|
+
self_deaf: boolean;
|
95
|
+
};
|
96
|
+
}
|
97
|
+
export interface ManagerOptions {
|
98
|
+
/** Use priority mode over least amount of player or load? */
|
99
|
+
usePriority?: boolean;
|
100
|
+
/** Use the least amount of players or least load? */
|
101
|
+
useNode?: "leastLoad" | "leastPlayers";
|
102
|
+
/** The array of nodes to connect to. */
|
103
|
+
nodes?: NodeOptions[];
|
104
|
+
/** The client ID to use. */
|
105
|
+
clientId?: string;
|
106
|
+
/** Value to use for the `Client-Name` header. */
|
107
|
+
clientName?: string;
|
108
|
+
/** The shard count. */
|
109
|
+
shards?: number;
|
110
|
+
/** A array of plugins to use. */
|
111
|
+
plugins?: Plugin[];
|
112
|
+
/** Whether players should automatically play the next song. */
|
113
|
+
autoPlay?: boolean;
|
114
|
+
/** An array of track properties to keep. `track` will always be present. */
|
115
|
+
trackPartial?: string[];
|
116
|
+
/** The default search platform to use, can be "youtube", "youtube music", "soundcloud" or deezer. */
|
117
|
+
defaultSearchPlatform?: SearchPlatform;
|
118
|
+
/** Whether the YouTube video titles should be replaced if the Author does not exactly match. */
|
119
|
+
replaceYouTubeCredentials?: boolean;
|
120
|
+
caches: {
|
121
|
+
/** Whether to cache the search results. */
|
122
|
+
enabled: boolean;
|
123
|
+
/** The time to cache the search results. */
|
124
|
+
time: number;
|
125
|
+
};
|
126
|
+
/**
|
127
|
+
* Function to send data to the websocket.
|
128
|
+
* @param id
|
129
|
+
* @param payload
|
130
|
+
*/
|
131
|
+
send(id: string, payload: Payload): void;
|
132
|
+
}
|
133
|
+
export type SearchPlatform = "deezer" | "soundcloud" | "youtube music" | "youtube" | "spotify" | "jiosaavn" | "tidal" | "applemusic" | "bandcamp" | "tiktok";
|
134
|
+
export interface SearchQuery {
|
135
|
+
/** The source to search from. */
|
136
|
+
source?: SearchPlatform | string;
|
137
|
+
/** The query to search for. */
|
138
|
+
query: string;
|
139
|
+
}
|
140
|
+
export interface LavalinkResponse {
|
141
|
+
loadType: LoadType;
|
142
|
+
data: TrackData[] | PlaylistRawData;
|
143
|
+
}
|
144
|
+
export interface SearchResult {
|
145
|
+
/** The load type of the result. */
|
146
|
+
loadType: LoadType;
|
147
|
+
/** The array of tracks from the result. */
|
148
|
+
tracks: Track[];
|
149
|
+
/** The playlist info if the load type is 'playlist'. */
|
150
|
+
playlist?: PlaylistData;
|
151
|
+
}
|
152
|
+
export interface PlaylistRawData {
|
153
|
+
info: {
|
154
|
+
/** The playlist name. */
|
155
|
+
name: string;
|
156
|
+
};
|
157
|
+
/** Addition info provided by plugins. */
|
158
|
+
pluginInfo: object;
|
159
|
+
/** The tracks of the playlist */
|
160
|
+
tracks: TrackData[];
|
161
|
+
}
|
162
|
+
export interface PlaylistData {
|
163
|
+
/** The playlist name. */
|
164
|
+
name: string;
|
165
|
+
/** The length of the playlist. */
|
166
|
+
duration: number;
|
167
|
+
/** The songs of the playlist. */
|
168
|
+
tracks: Track[];
|
169
|
+
}
|
170
|
+
export interface ManagerEvents {
|
171
|
+
NodeCreate: (node: Node) => void;
|
172
|
+
NodeDestroy: (node: Node) => void;
|
173
|
+
NodeConnect: (node: Node) => void;
|
174
|
+
NodeReconnect: (node: Node) => void;
|
175
|
+
NodeDisconnect: (node: Node, reason: {
|
176
|
+
code?: number;
|
177
|
+
reason?: string;
|
178
|
+
}) => void;
|
179
|
+
NodeError: (node: Node, error: Error) => void;
|
180
|
+
NodeRaw: (payload: unknown) => void;
|
181
|
+
PlayerCreate: (player: Player) => void;
|
182
|
+
PlayerDestroy: (player: Player) => void;
|
183
|
+
PlayerStateUpdate: (oldPlayer: Player, newPlayer: Player) => void;
|
184
|
+
PlayerMove: (player: Player, initChannel: string, newChannel: string) => void;
|
185
|
+
PlayerDisconnect: (player: Player, oldChannel: string) => void;
|
186
|
+
QueueEnd: (player: Player, track: Track | UnresolvedTrack, payload: TrackEndEvent) => void;
|
187
|
+
SocketClosed: (player: Player, payload: WebSocketClosedEvent) => void;
|
188
|
+
TrackStart: (player: Player, track: Track, payload: TrackStartEvent) => void;
|
189
|
+
TrackEnd: (player: Player, track: Track, payload: TrackEndEvent) => void;
|
190
|
+
TrackStuck: (player: Player, track: Track, payload: TrackStuckEvent) => void;
|
191
|
+
TrackError: (player: Player, track: Track | UnresolvedTrack, payload: TrackExceptionEvent) => void;
|
192
|
+
}
|