lavalink-client 2.2.1 → 2.3.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/README.md +140 -20
- package/dist/cjs/index.d.ts +7 -1
- package/dist/cjs/index.js +7 -1
- package/dist/cjs/structures/Constants.d.ts +40 -0
- package/dist/cjs/structures/Constants.js +244 -0
- package/dist/cjs/structures/CustomSearches/BandCampSearch.d.ts +2 -2
- package/dist/cjs/structures/Filters.d.ts +2 -217
- package/dist/cjs/structures/Filters.js +12 -236
- package/dist/cjs/structures/LavalinkManager.d.ts +31 -166
- package/dist/cjs/structures/LavalinkManager.js +60 -8
- package/dist/cjs/structures/LavalinkManagerStatics.d.ts +1 -1
- package/dist/cjs/structures/LavalinkManagerStatics.js +1 -1
- package/dist/cjs/structures/Node.d.ts +15 -156
- package/dist/cjs/structures/Node.js +140 -51
- package/dist/cjs/structures/NodeManager.d.ts +54 -52
- package/dist/cjs/structures/NodeManager.js +77 -5
- package/dist/cjs/structures/Player.d.ts +31 -124
- package/dist/cjs/structures/Player.js +78 -43
- package/dist/cjs/structures/Queue.d.ts +113 -42
- package/dist/cjs/structures/Queue.js +169 -8
- package/dist/cjs/structures/Types/Filters.d.ts +190 -0
- package/dist/cjs/structures/Types/Manager.d.ts +184 -0
- package/dist/cjs/structures/Types/Manager.js +2 -0
- package/dist/cjs/structures/Types/Node.d.ts +216 -0
- package/dist/cjs/structures/Types/Node.js +2 -0
- package/dist/cjs/structures/Types/Player.d.ts +108 -0
- package/dist/cjs/structures/Types/Player.js +2 -0
- package/dist/cjs/structures/Types/Queue.d.ts +34 -0
- package/dist/cjs/structures/Types/Queue.js +2 -0
- package/dist/cjs/structures/{Track.d.ts → Types/Track.d.ts} +4 -2
- package/dist/cjs/structures/Types/Track.js +2 -0
- package/dist/cjs/structures/Types/Utils.d.ts +367 -0
- package/dist/cjs/structures/Types/Utils.js +2 -0
- package/dist/cjs/structures/Utils.d.ts +13 -369
- package/dist/cjs/structures/Utils.js +40 -18
- package/dist/esm/index.d.ts +7 -1
- package/dist/esm/index.js +7 -1
- package/dist/esm/structures/Constants.d.ts +40 -0
- package/dist/esm/structures/Constants.js +241 -0
- package/dist/esm/structures/CustomSearches/BandCampSearch.d.ts +2 -2
- package/dist/esm/structures/Filters.d.ts +2 -217
- package/dist/esm/structures/Filters.js +7 -231
- package/dist/esm/structures/LavalinkManager.d.ts +31 -166
- package/dist/esm/structures/LavalinkManager.js +58 -6
- package/dist/esm/structures/LavalinkManagerStatics.d.ts +1 -1
- package/dist/esm/structures/LavalinkManagerStatics.js +1 -1
- package/dist/esm/structures/Node.d.ts +15 -156
- package/dist/esm/structures/Node.js +132 -43
- package/dist/esm/structures/NodeManager.d.ts +54 -52
- package/dist/esm/structures/NodeManager.js +74 -2
- package/dist/esm/structures/Player.d.ts +31 -124
- package/dist/esm/structures/Player.js +77 -42
- package/dist/esm/structures/Queue.d.ts +113 -42
- package/dist/esm/structures/Queue.js +169 -8
- package/dist/esm/structures/Types/Filters.d.ts +190 -0
- package/dist/esm/structures/Types/Manager.d.ts +184 -0
- package/dist/esm/structures/Types/Manager.js +1 -0
- package/dist/esm/structures/Types/Node.d.ts +216 -0
- package/dist/esm/structures/Types/Node.js +1 -0
- package/dist/esm/structures/Types/Player.d.ts +108 -0
- package/dist/esm/structures/Types/Player.js +1 -0
- package/dist/esm/structures/Types/Queue.d.ts +34 -0
- package/dist/esm/structures/Types/Queue.js +1 -0
- package/dist/{types/structures → esm/structures/Types}/Track.d.ts +4 -2
- package/dist/esm/structures/Types/Track.js +1 -0
- package/dist/esm/structures/Types/Utils.d.ts +367 -0
- package/dist/esm/structures/Types/Utils.js +1 -0
- package/dist/esm/structures/Utils.d.ts +13 -369
- package/dist/esm/structures/Utils.js +40 -18
- package/dist/types/index.d.ts +7 -1
- package/dist/types/structures/Constants.d.ts +40 -0
- package/dist/types/structures/CustomSearches/BandCampSearch.d.ts +2 -2
- package/dist/types/structures/Filters.d.ts +2 -217
- package/dist/types/structures/LavalinkManager.d.ts +31 -166
- package/dist/types/structures/LavalinkManagerStatics.d.ts +1 -1
- package/dist/types/structures/Node.d.ts +15 -156
- package/dist/types/structures/NodeManager.d.ts +54 -52
- package/dist/types/structures/Player.d.ts +31 -124
- package/dist/types/structures/Queue.d.ts +113 -42
- package/dist/types/structures/Types/Filters.d.ts +190 -0
- package/dist/types/structures/Types/Manager.d.ts +184 -0
- package/dist/types/structures/Types/Node.d.ts +216 -0
- package/dist/types/structures/Types/Player.d.ts +108 -0
- package/dist/types/structures/Types/Queue.d.ts +34 -0
- package/dist/{esm/structures → types/structures/Types}/Track.d.ts +4 -2
- package/dist/types/structures/Types/Utils.d.ts +367 -0
- package/dist/types/structures/Utils.d.ts +13 -369
- package/package.json +1 -1
- /package/dist/cjs/structures/{Track.js → Types/Filters.js} +0 -0
- /package/dist/esm/structures/{Track.js → Types/Filters.js} +0 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { Player } from "../Player";
|
|
2
|
+
import type { LavalinkNodeOptions } from "./Node";
|
|
3
|
+
import type { DestroyReasonsType, PlayerJson } from "./Player";
|
|
4
|
+
import type { ManagerQueueOptions } from "./Queue";
|
|
5
|
+
import type { Track, UnresolvedTrack } from "./Track";
|
|
6
|
+
import type { GuildShardPayload, SearchPlatform, SponsorBlockChaptersLoaded, SponsorBlockChapterStarted, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, TrackExceptionEvent, TrackEndEvent, TrackStuckEvent, WebSocketClosedEvent, TrackStartEvent } from "./Utils";
|
|
7
|
+
/**
|
|
8
|
+
* The events from the lavalink Manager
|
|
9
|
+
*/
|
|
10
|
+
export interface LavalinkManagerEvents {
|
|
11
|
+
/**
|
|
12
|
+
* Emitted when a Track started playing.
|
|
13
|
+
* @event Manager#trackStart
|
|
14
|
+
*/
|
|
15
|
+
"trackStart": (player: Player, track: Track | null, payload: TrackStartEvent) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Emitted when a Track finished.
|
|
18
|
+
* @event Manager#trackEnd
|
|
19
|
+
*/
|
|
20
|
+
"trackEnd": (player: Player, track: Track | null, payload: TrackEndEvent) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Emitted when a Track got stuck while playing.
|
|
23
|
+
* @event Manager#trackStuck
|
|
24
|
+
*/
|
|
25
|
+
"trackStuck": (player: Player, track: Track | null, payload: TrackStuckEvent) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Emitted when a Track errored.
|
|
28
|
+
* @event Manager#trackError
|
|
29
|
+
*/
|
|
30
|
+
"trackError": (player: Player, track: Track | UnresolvedTrack | null, payload: TrackExceptionEvent) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Emitted when the Playing finished and no more tracks in the queue.
|
|
33
|
+
* @event Manager#queueEnd
|
|
34
|
+
*/
|
|
35
|
+
"queueEnd": (player: Player, track: Track | UnresolvedTrack | null, payload: TrackEndEvent | TrackStuckEvent | TrackExceptionEvent) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Emitted when a Player is created.
|
|
38
|
+
* @event Manager#playerCreate
|
|
39
|
+
*/
|
|
40
|
+
"playerCreate": (player: Player) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Emitted when a Player is moved within the channel.
|
|
43
|
+
* @event Manager#playerMove
|
|
44
|
+
*/
|
|
45
|
+
"playerMove": (player: Player, oldVoiceChannelId: string, newVoiceChannelId: string) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Emitted when a Player is disconnected from a channel.
|
|
48
|
+
* @event Manager#playerDisconnect
|
|
49
|
+
*/
|
|
50
|
+
"playerDisconnect": (player: Player, voiceChannelId: string) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Emitted when a Node-Socket got closed for a specific Player.
|
|
53
|
+
* Usually emits when the audio websocket to discord is closed, This can happen for various reasons (normal and abnormal), e.g. when using an expired voice server update. 4xxx codes are usually bad.
|
|
54
|
+
*
|
|
55
|
+
* So this is just information, normally lavalink should handle disconnections
|
|
56
|
+
*
|
|
57
|
+
* Discord Docs:
|
|
58
|
+
* @link https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes
|
|
59
|
+
*
|
|
60
|
+
* Lavalink Docs:
|
|
61
|
+
* @link https://lavalink.dev/api/websocket.html#websocketclosedevent
|
|
62
|
+
* @event Manager#playerSocketClosed
|
|
63
|
+
*/
|
|
64
|
+
"playerSocketClosed": (player: Player, payload: WebSocketClosedEvent) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Emitted when a Player get's destroyed
|
|
67
|
+
* @event Manager#playerDestroy
|
|
68
|
+
*/
|
|
69
|
+
"playerDestroy": (player: Player, destroyReason?: DestroyReasonsType) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Always emits when the player (on lavalink side) got updated
|
|
72
|
+
* @event Manager#playerUpdate
|
|
73
|
+
*/
|
|
74
|
+
"playerUpdate": (oldPlayerJson: PlayerJson, newPlayer: Player) => void;
|
|
75
|
+
/**
|
|
76
|
+
* SPONSORBLOCK-PLUGIN EVENT
|
|
77
|
+
* Emitted when Segments are loaded
|
|
78
|
+
* @link https://github.com/topi314/Sponsorblock-Plugin#segmentsloaded
|
|
79
|
+
* @event Manager#trackError
|
|
80
|
+
*/
|
|
81
|
+
"SegmentsLoaded": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockSegmentsLoaded) => void;
|
|
82
|
+
/**
|
|
83
|
+
* SPONSORBLOCK-PLUGIN EVENT
|
|
84
|
+
* Emitted when a specific Segment was skipped
|
|
85
|
+
* @link https://github.com/topi314/Sponsorblock-Plugin#segmentskipped
|
|
86
|
+
* @event Manager#trackError
|
|
87
|
+
*/
|
|
88
|
+
"SegmentSkipped": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockSegmentSkipped) => void;
|
|
89
|
+
/**
|
|
90
|
+
* SPONSORBLOCK-PLUGIN EVENT
|
|
91
|
+
* Emitted when a specific Chapter starts playing
|
|
92
|
+
* @link https://github.com/topi314/Sponsorblock-Plugin#chapterstarted
|
|
93
|
+
* @event Manager#trackError
|
|
94
|
+
*/
|
|
95
|
+
"ChapterStarted": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockChapterStarted) => void;
|
|
96
|
+
/**
|
|
97
|
+
* SPONSORBLOCK-PLUGIN EVENT
|
|
98
|
+
* Emitted when Chapters are loaded
|
|
99
|
+
* @link https://github.com/topi314/Sponsorblock-Plugin#chaptersloaded
|
|
100
|
+
* @event Manager#trackError
|
|
101
|
+
*/
|
|
102
|
+
"ChaptersLoaded": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockChaptersLoaded) => void;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The Bot client Options needed for the manager
|
|
106
|
+
*/
|
|
107
|
+
export interface BotClientOptions {
|
|
108
|
+
/** Bot Client Id */
|
|
109
|
+
id: string;
|
|
110
|
+
/** Bot Client Username */
|
|
111
|
+
username?: string;
|
|
112
|
+
/** So users can pass entire objects / classes */
|
|
113
|
+
[x: string | number | symbol]: unknown;
|
|
114
|
+
}
|
|
115
|
+
/** Sub Manager Options, for player specific things */
|
|
116
|
+
export interface ManagerPlayerOptions {
|
|
117
|
+
/** If the Lavalink Volume should be decremented by x number */
|
|
118
|
+
volumeDecrementer?: number;
|
|
119
|
+
/** How often it should update the the player Position */
|
|
120
|
+
clientBasedPositionUpdateInterval?: number;
|
|
121
|
+
/** What should be used as a searchPlatform, if no source was provided during the query */
|
|
122
|
+
defaultSearchPlatform?: SearchPlatform;
|
|
123
|
+
/** Applies the volume via a filter, not via the lavalink volume transformer */
|
|
124
|
+
applyVolumeAsFilter?: boolean;
|
|
125
|
+
/** Transforms the saved data of a requested user */
|
|
126
|
+
requesterTransformer?: (requester: unknown) => unknown;
|
|
127
|
+
/** What lavalink-client should do when the player reconnects */
|
|
128
|
+
onDisconnect?: {
|
|
129
|
+
/** Try to reconnect? -> If fails -> Destroy */
|
|
130
|
+
autoReconnect?: boolean;
|
|
131
|
+
/** Instantly destroy player (overrides autoReconnect) | Don't provide == disable feature*/
|
|
132
|
+
destroyPlayer?: boolean;
|
|
133
|
+
};
|
|
134
|
+
onEmptyQueue?: {
|
|
135
|
+
/** Get's executed onEmptyQueue -> You can do any track queue previous transformations, if you add a track to the queue -> it will play it, if not queueEnd will execute! */
|
|
136
|
+
autoPlayFunction?: (player: Player, lastPlayedTrack: Track) => Promise<void>;
|
|
137
|
+
destroyAfterMs?: number;
|
|
138
|
+
};
|
|
139
|
+
useUnresolvedData?: boolean;
|
|
140
|
+
}
|
|
141
|
+
/** Manager Options used to create the manager */
|
|
142
|
+
export interface ManagerOptions {
|
|
143
|
+
/** The Node Options, for all Nodes! (on init) */
|
|
144
|
+
nodes: LavalinkNodeOptions[];
|
|
145
|
+
/** @async The Function to send the voice connection changes from Lavalink to Discord */
|
|
146
|
+
sendToShard: (guildId: string, payload: GuildShardPayload) => void;
|
|
147
|
+
/** The Bot Client's Data for Authorization */
|
|
148
|
+
client?: BotClientOptions;
|
|
149
|
+
/** QueueOptions for all Queues */
|
|
150
|
+
queueOptions?: ManagerQueueOptions;
|
|
151
|
+
/** PlayerOptions for all Players */
|
|
152
|
+
playerOptions?: ManagerPlayerOptions;
|
|
153
|
+
/** If it should skip to the next Track on TrackEnd / TrackError etc. events */
|
|
154
|
+
autoSkip?: boolean;
|
|
155
|
+
/** If it should skip to the next Track if track.resolve errors while trying to play a track. */
|
|
156
|
+
autoSkipOnResolveError?: boolean;
|
|
157
|
+
/** If it should emit only new (unique) songs and not when a looping track (or similar) is plaid, default false */
|
|
158
|
+
emitNewSongsOnly?: boolean;
|
|
159
|
+
/** Only allow link requests with links either matching some of that regExp or including some of that string */
|
|
160
|
+
linksWhitelist?: (RegExp | string)[];
|
|
161
|
+
/** Never allow link requests with links either matching some of that regExp or including some of that string (doesn't even allow if it's whitelisted) */
|
|
162
|
+
linksBlacklist?: (RegExp | string)[];
|
|
163
|
+
/** If links should be allowed or not. If set to false, it will throw an error if a link was provided. */
|
|
164
|
+
linksAllowed?: boolean;
|
|
165
|
+
/** Advanced Options for the Library, which may or may not be "library breaking" */
|
|
166
|
+
advancedOptions?: {
|
|
167
|
+
/** Max duration for that the filter fix duration works (in ms) - default is 8mins */
|
|
168
|
+
maxFilterFixDuration?: number;
|
|
169
|
+
/** optional */
|
|
170
|
+
debugOptions?: {
|
|
171
|
+
/** For logging custom searches */
|
|
172
|
+
logCustomSearches?: boolean;
|
|
173
|
+
/** logs for debugging the "no-Audio" playing error */
|
|
174
|
+
noAudio?: boolean;
|
|
175
|
+
/** For Logging the Destroy function */
|
|
176
|
+
playerDestroy?: {
|
|
177
|
+
/** To show the debug reason at all times. */
|
|
178
|
+
debugLog?: boolean;
|
|
179
|
+
/** If you get 'Error: Use Player#destroy("reason") not LavalinkManager#deletePlayer() to stop the Player' put it on true */
|
|
180
|
+
dontThrowError?: boolean;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type internal from "stream";
|
|
3
|
+
import type { LavalinkNode } from "../Node";
|
|
4
|
+
import type { DestroyReasonsType } from "./Player";
|
|
5
|
+
import type { InvalidLavalinkRestRequest, LavalinkPlayer } from "./Utils";
|
|
6
|
+
/** Ability to manipulate fetch requests */
|
|
7
|
+
export type ModifyRequest = (options: RequestInit & {
|
|
8
|
+
path: string;
|
|
9
|
+
extraQueryUrlParams?: URLSearchParams;
|
|
10
|
+
}) => void;
|
|
11
|
+
export type SponsorBlockSegment = "sponsor" | "selfpromo" | "interaction" | "intro" | "outro" | "preview" | "music_offtopic" | "filler";
|
|
12
|
+
/**
|
|
13
|
+
* Node Options for creating a lavalink node
|
|
14
|
+
*/
|
|
15
|
+
export interface LavalinkNodeOptions {
|
|
16
|
+
/** The Lavalink Server-Ip / Domain-URL */
|
|
17
|
+
host: string;
|
|
18
|
+
/** The Lavalink Connection Port */
|
|
19
|
+
port: number;
|
|
20
|
+
/** The Lavalink Password / Authorization-Key */
|
|
21
|
+
authorization: string;
|
|
22
|
+
/** Does the Server use ssl (https) */
|
|
23
|
+
secure?: boolean;
|
|
24
|
+
/** RESUME THE PLAYER? by providing a sessionid on the node-creation */
|
|
25
|
+
sessionId?: string;
|
|
26
|
+
/** Add a Custom ID to the node, for later use */
|
|
27
|
+
id?: string;
|
|
28
|
+
/** Voice Regions of this Node */
|
|
29
|
+
regions?: string[];
|
|
30
|
+
/** The retryAmount for the node. */
|
|
31
|
+
retryAmount?: number;
|
|
32
|
+
/** The retryDelay for the node. */
|
|
33
|
+
retryDelay?: number;
|
|
34
|
+
/** signal for cancelling requests - default: AbortSignal.timeout(options.requestSignalTimeoutMS || 10000) - put <= 0 to disable */
|
|
35
|
+
requestSignalTimeoutMS?: number;
|
|
36
|
+
/** Close on error */
|
|
37
|
+
closeOnError?: boolean;
|
|
38
|
+
/** Heartbeat interval , set to <= 0 to disable heartbeat system */
|
|
39
|
+
heartBeatInterval?: 30000;
|
|
40
|
+
/** Recommended, to check wether the client is still connected or not on the stats endpoint */
|
|
41
|
+
enablePingOnStatsCheck?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Memory Stats object from lavalink
|
|
45
|
+
*/
|
|
46
|
+
export interface MemoryStats {
|
|
47
|
+
/** The free memory of the allocated amount. */
|
|
48
|
+
free: number;
|
|
49
|
+
/** The used memory of the allocated amount. */
|
|
50
|
+
used: number;
|
|
51
|
+
/** The total allocated memory. */
|
|
52
|
+
allocated: number;
|
|
53
|
+
/** The reservable memory. */
|
|
54
|
+
reservable: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* CPU Stats object from lavalink
|
|
58
|
+
*/
|
|
59
|
+
export interface CPUStats {
|
|
60
|
+
/** The core amount the host machine has. */
|
|
61
|
+
cores: number;
|
|
62
|
+
/** The system load. */
|
|
63
|
+
systemLoad: number;
|
|
64
|
+
/** The lavalink load. */
|
|
65
|
+
lavalinkLoad: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* FrameStats Object from lavalink
|
|
69
|
+
*/
|
|
70
|
+
export interface FrameStats {
|
|
71
|
+
/** The amount of sent frames. */
|
|
72
|
+
sent?: number;
|
|
73
|
+
/** The amount of nulled frames. */
|
|
74
|
+
nulled?: number;
|
|
75
|
+
/** The amount of deficit frames. */
|
|
76
|
+
deficit?: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* BaseNodeStats object from Lavalink
|
|
80
|
+
*/
|
|
81
|
+
export interface BaseNodeStats {
|
|
82
|
+
/** The amount of players on the node. */
|
|
83
|
+
players: number;
|
|
84
|
+
/** The amount of playing players on the node. */
|
|
85
|
+
playingPlayers: number;
|
|
86
|
+
/** The uptime for the node. */
|
|
87
|
+
uptime: number;
|
|
88
|
+
/** The memory stats for the node. */
|
|
89
|
+
memory: MemoryStats;
|
|
90
|
+
/** The cpu stats for the node. */
|
|
91
|
+
cpu: CPUStats;
|
|
92
|
+
/** The frame stats for the node. */
|
|
93
|
+
frameStats: FrameStats;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Interface for nodeStats from lavalink
|
|
97
|
+
*/
|
|
98
|
+
export interface NodeStats extends BaseNodeStats {
|
|
99
|
+
/** The frame stats for the node. */
|
|
100
|
+
frameStats: FrameStats;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Entire lavalink information object from lavalink
|
|
104
|
+
*/
|
|
105
|
+
export interface LavalinkInfo {
|
|
106
|
+
/** The version of this Lavalink server */
|
|
107
|
+
version: VersionObject;
|
|
108
|
+
/** The millisecond unix timestamp when this Lavalink jar was built */
|
|
109
|
+
buildTime: number;
|
|
110
|
+
/** The git information of this Lavalink server */
|
|
111
|
+
git: GitObject;
|
|
112
|
+
/** The JVM version this Lavalink server runs on */
|
|
113
|
+
jvm: string;
|
|
114
|
+
/** The Lavaplayer version being used by this server */
|
|
115
|
+
lavaplayer: string;
|
|
116
|
+
/** The enabled source managers for this server */
|
|
117
|
+
sourceManagers: string[];
|
|
118
|
+
/** The enabled filters for this server */
|
|
119
|
+
filters: string[];
|
|
120
|
+
/** The enabled plugins for this server */
|
|
121
|
+
plugins: PluginObject[];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Lavalink's version object from lavalink
|
|
125
|
+
*/
|
|
126
|
+
export interface VersionObject {
|
|
127
|
+
/** The full version string of this Lavalink server */
|
|
128
|
+
semver: string;
|
|
129
|
+
/** The major version of this Lavalink server */
|
|
130
|
+
major: number;
|
|
131
|
+
/** The minor version of this Lavalink server */
|
|
132
|
+
minor: number;
|
|
133
|
+
/** The patch version of this Lavalink server */
|
|
134
|
+
patch: internal;
|
|
135
|
+
/** The pre-release version according to semver as a . separated list of identifiers */
|
|
136
|
+
preRelease?: string;
|
|
137
|
+
/** The build metadata according to semver as a . separated list of identifiers */
|
|
138
|
+
build?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Git information object from lavalink
|
|
142
|
+
*/
|
|
143
|
+
export interface GitObject {
|
|
144
|
+
/** The branch this Lavalink server was built on */
|
|
145
|
+
branch: string;
|
|
146
|
+
/** The commit this Lavalink server was built on */
|
|
147
|
+
commit: string;
|
|
148
|
+
/** The millisecond unix timestamp for when the commit was created */
|
|
149
|
+
commitTime: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Lavalink's plugins object from lavalink's plugin
|
|
153
|
+
*/
|
|
154
|
+
export interface PluginObject {
|
|
155
|
+
/** The name of the plugin */
|
|
156
|
+
name: string;
|
|
157
|
+
/** The version of the plugin */
|
|
158
|
+
version: string;
|
|
159
|
+
}
|
|
160
|
+
export type LavalinkNodeIdentifier = string;
|
|
161
|
+
export interface NodeManagerEvents {
|
|
162
|
+
/**
|
|
163
|
+
* Emitted when a Node is created.
|
|
164
|
+
* @event Manager.nodeManager#create
|
|
165
|
+
*/
|
|
166
|
+
"create": (node: LavalinkNode) => void;
|
|
167
|
+
/**
|
|
168
|
+
* Emitted when a Node is destroyed.
|
|
169
|
+
* @event Manager.nodeManager#destroy
|
|
170
|
+
*/
|
|
171
|
+
"destroy": (node: LavalinkNode, destroyReason?: DestroyReasonsType) => void;
|
|
172
|
+
/**
|
|
173
|
+
* Emitted when a Node is connected.
|
|
174
|
+
* @event Manager.nodeManager#connect
|
|
175
|
+
*/
|
|
176
|
+
"connect": (node: LavalinkNode) => void;
|
|
177
|
+
/**
|
|
178
|
+
* Emitted when a Node is reconnecting.
|
|
179
|
+
* @event Manager.nodeManager#reconnecting
|
|
180
|
+
*/
|
|
181
|
+
"reconnecting": (node: LavalinkNode) => void;
|
|
182
|
+
/**
|
|
183
|
+
* Emitted When a node starts to reconnect (if you have a reconnection delay, the reconnecting event will be emitted after the retryDelay.)
|
|
184
|
+
* Useful to check wether the internal node reconnect system works or not
|
|
185
|
+
* @event Manager.nodeManager#reconnectinprogress
|
|
186
|
+
*/
|
|
187
|
+
"reconnectinprogress": (node: LavalinkNode) => void;
|
|
188
|
+
/**
|
|
189
|
+
* Emitted when a Node is disconnects.
|
|
190
|
+
* @event Manager.nodeManager#disconnect
|
|
191
|
+
*/
|
|
192
|
+
"disconnect": (node: LavalinkNode, reason: {
|
|
193
|
+
code?: number;
|
|
194
|
+
reason?: string;
|
|
195
|
+
}) => void;
|
|
196
|
+
/**
|
|
197
|
+
* Emitted when a Node is error.
|
|
198
|
+
* @event Manager.nodeManager#error
|
|
199
|
+
*/
|
|
200
|
+
"error": (node: LavalinkNode, error: Error, payload?: unknown) => void;
|
|
201
|
+
/**
|
|
202
|
+
* Emits every single Node event.
|
|
203
|
+
* @event Manager.nodeManager#raw
|
|
204
|
+
*/
|
|
205
|
+
"raw": (node: LavalinkNode, payload: unknown) => void;
|
|
206
|
+
/**
|
|
207
|
+
* Emits when the node connects resumed. You then need to create all players within this event for your usecase.
|
|
208
|
+
* Aka for that you need to be able to save player data like vc channel + text channel in a db and then sync it again
|
|
209
|
+
* @event Manager.nodeManager#nodeResumed
|
|
210
|
+
*/
|
|
211
|
+
"resumed": (node: LavalinkNode, paylaod: {
|
|
212
|
+
resumed: true;
|
|
213
|
+
sessionId: string;
|
|
214
|
+
op: "ready";
|
|
215
|
+
}, players: LavalinkPlayer[] | InvalidLavalinkRestRequest) => void;
|
|
216
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { DestroyReasons } from "../Constants";
|
|
2
|
+
import type { LavalinkNode } from "../Node";
|
|
3
|
+
import type { EQBand, FilterData, LavalinkFilterData } from "./Filters";
|
|
4
|
+
import type { Track, UnresolvedTrack } from "./Track";
|
|
5
|
+
import type { Base64, LavalinkPlayerVoiceOptions } from "./Utils";
|
|
6
|
+
export type DestroyReasonsType = keyof typeof DestroyReasons | string;
|
|
7
|
+
export interface PlayerJson {
|
|
8
|
+
/** Guild Id where the player was playing in */
|
|
9
|
+
guildId: string;
|
|
10
|
+
/** Options provided to the player */
|
|
11
|
+
options: PlayerOptions;
|
|
12
|
+
/** Voice Channel Id the player was playing in */
|
|
13
|
+
voiceChannelId: string;
|
|
14
|
+
/** Text Channel Id the player was synced to */
|
|
15
|
+
textChannelId?: string;
|
|
16
|
+
/** Position the player was at */
|
|
17
|
+
position: number;
|
|
18
|
+
/** Lavalink's position the player was at */
|
|
19
|
+
lastPosition: number;
|
|
20
|
+
/** Last time the position was sent from lavalink */
|
|
21
|
+
lastPositionChange: number;
|
|
22
|
+
/** Volume in % from the player (without volumeDecrementer) */
|
|
23
|
+
volume: number;
|
|
24
|
+
/** Real Volume used in lavalink (with the volumeDecrementer) */
|
|
25
|
+
lavalinkVolume: number;
|
|
26
|
+
/** The repeatmode from the player */
|
|
27
|
+
repeatMode: RepeatMode;
|
|
28
|
+
/** Pause state */
|
|
29
|
+
paused: boolean;
|
|
30
|
+
/** Wether the player was playing or not */
|
|
31
|
+
playing: boolean;
|
|
32
|
+
/** When the player was created */
|
|
33
|
+
createdTimeStamp?: number;
|
|
34
|
+
/** All current used fitlers Data */
|
|
35
|
+
filters: FilterData;
|
|
36
|
+
/** The player's ping object */
|
|
37
|
+
ping: {
|
|
38
|
+
/** Ping to the voice websocket server */
|
|
39
|
+
ws: number;
|
|
40
|
+
/** Avg. calc. Ping to the lavalink server */
|
|
41
|
+
lavalink: number;
|
|
42
|
+
};
|
|
43
|
+
/** Equalizer Bands used in lavalink */
|
|
44
|
+
equalizer: EQBand[];
|
|
45
|
+
/** The Id of the last used node */
|
|
46
|
+
nodeId?: string;
|
|
47
|
+
/** The SessionId of the node */
|
|
48
|
+
nodeSessionId?: string;
|
|
49
|
+
}
|
|
50
|
+
export type RepeatMode = "queue" | "track" | "off";
|
|
51
|
+
export interface PlayerOptions {
|
|
52
|
+
/** Guild id of the player */
|
|
53
|
+
guildId: string;
|
|
54
|
+
/** The Voice Channel Id */
|
|
55
|
+
voiceChannelId: string;
|
|
56
|
+
/** The Text Channel Id of the Player */
|
|
57
|
+
textChannelId?: string;
|
|
58
|
+
/** instantly change volume with the one play request */
|
|
59
|
+
volume?: number;
|
|
60
|
+
/** VC Region for node selections */
|
|
61
|
+
vcRegion?: string;
|
|
62
|
+
/** if it should join deafened */
|
|
63
|
+
selfDeaf?: boolean;
|
|
64
|
+
/** If it should join muted */
|
|
65
|
+
selfMute?: boolean;
|
|
66
|
+
/** If it should use a specific lavalink node */
|
|
67
|
+
node?: LavalinkNode | string;
|
|
68
|
+
/** If when applying filters, it should use the insta apply filters fix */
|
|
69
|
+
instaUpdateFiltersFix?: boolean;
|
|
70
|
+
/** If a volume should be applied via filters instead of lavalink-volume */
|
|
71
|
+
applyVolumeAsFilter?: boolean;
|
|
72
|
+
}
|
|
73
|
+
export type anyObject = {
|
|
74
|
+
[key: string | number]: string | number | null | anyObject;
|
|
75
|
+
};
|
|
76
|
+
export interface BasePlayOptions {
|
|
77
|
+
/** The position to start the track. */
|
|
78
|
+
position?: number;
|
|
79
|
+
/** The position to end the track. */
|
|
80
|
+
endTime?: number;
|
|
81
|
+
/** If to start "paused" */
|
|
82
|
+
paused?: boolean;
|
|
83
|
+
/** The Volume to start with */
|
|
84
|
+
volume?: number;
|
|
85
|
+
/** The Lavalink Filters to use | only with the new REST API */
|
|
86
|
+
filters?: Partial<LavalinkFilterData>;
|
|
87
|
+
/** Voice Update for Lavalink */
|
|
88
|
+
voice?: LavalinkPlayerVoiceOptions;
|
|
89
|
+
}
|
|
90
|
+
export interface LavalinkPlayOptions extends BasePlayOptions {
|
|
91
|
+
/** Which Track to play | don't provide, if it should pick from the Queue */
|
|
92
|
+
track?: {
|
|
93
|
+
/** The track encoded base64 string to use instead of the one from the queue system */
|
|
94
|
+
encoded?: Base64 | null;
|
|
95
|
+
/** The identifier of the track to use */
|
|
96
|
+
identifier?: string;
|
|
97
|
+
/** Custom User Data for the track to provide, will then be on the userData object from the track */
|
|
98
|
+
userData?: anyObject;
|
|
99
|
+
/** The Track requester for when u provide encodedTrack / identifer */
|
|
100
|
+
requester?: unknown;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export interface PlayOptions extends LavalinkPlayOptions {
|
|
104
|
+
/** Whether to not replace the track if a play payload is sent. */
|
|
105
|
+
noReplace?: boolean;
|
|
106
|
+
/** Adds track on queue and skips to it */
|
|
107
|
+
clientTrack?: Track | UnresolvedTrack;
|
|
108
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Track, UnresolvedTrack } from "./Track";
|
|
2
|
+
export interface StoredQueue {
|
|
3
|
+
current: Track | null;
|
|
4
|
+
previous: Track[];
|
|
5
|
+
tracks: (Track | UnresolvedTrack)[];
|
|
6
|
+
}
|
|
7
|
+
export interface QueueStoreManager extends Record<string, any> {
|
|
8
|
+
/** @async get a Value (MUST RETURN UNPARSED!) */
|
|
9
|
+
get: (guildId: unknown) => Promise<unknown>;
|
|
10
|
+
/** @async Set a value inside a guildId (MUST BE UNPARSED) */
|
|
11
|
+
set: (guildId: unknown, value: unknown) => Promise<unknown>;
|
|
12
|
+
/** @async Delete a Database Value based of it's guildId */
|
|
13
|
+
delete: (guildId: unknown) => Promise<unknown>;
|
|
14
|
+
/** @async Transform the value(s) inside of the QueueStoreManager (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
|
|
15
|
+
stringify: (value: unknown) => Promise<unknown>;
|
|
16
|
+
/** @async Parse the saved value back to the Queue (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
|
|
17
|
+
parse: (value: unknown) => Promise<Partial<StoredQueue>>;
|
|
18
|
+
}
|
|
19
|
+
export interface ManagerQueueOptions {
|
|
20
|
+
/** Maximum Amount of tracks for the queue.previous array. Set to 0 to not save previous songs. Defaults to 25 Tracks */
|
|
21
|
+
maxPreviousTracks?: number;
|
|
22
|
+
/** Custom Queue Store option */
|
|
23
|
+
queueStore?: QueueStoreManager;
|
|
24
|
+
/** Custom Queue Watcher class */
|
|
25
|
+
queueChangesWatcher?: QueueChangesWatcher;
|
|
26
|
+
}
|
|
27
|
+
export interface QueueChangesWatcher {
|
|
28
|
+
/** get a Value (MUST RETURN UNPARSED!) */
|
|
29
|
+
tracksAdd: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
|
|
30
|
+
/** Set a value inside a guildId (MUST BE UNPARSED) */
|
|
31
|
+
tracksRemoved: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
|
|
32
|
+
/** Set a value inside a guildId (MUST BE UNPARSED) */
|
|
33
|
+
shuffled: (guildId: string, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
|
|
34
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Player } from "../Player";
|
|
2
|
+
import type { anyObject } from "./Player";
|
|
3
|
+
import type { Base64 } from "./Utils";
|
|
3
4
|
/** Sourcenames provided by lavalink server */
|
|
4
5
|
export type LavalinkSourceNames = "youtube" | "youtubemusic" | "soundcloud" | "bandcamp" | "twitch";
|
|
5
6
|
/** Source Names provided by lava src plugin */
|
|
@@ -81,6 +82,7 @@ export interface PluginInfo {
|
|
|
81
82
|
uri?: string;
|
|
82
83
|
/** You can put specific track information here, to transform the tracks... */
|
|
83
84
|
clientData?: {
|
|
85
|
+
previousTrack?: boolean;
|
|
84
86
|
[key: string]: any;
|
|
85
87
|
};
|
|
86
88
|
}
|