lavalink-client 1.1.25 → 1.2.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 +26 -1
- package/dist/cjs/structures/CustomSearches/BandCampSearch.js +1 -0
- package/dist/cjs/structures/LavalinkManager.d.ts +51 -12
- package/dist/cjs/structures/LavalinkManager.js +21 -14
- package/dist/cjs/structures/Node.d.ts +10 -1
- package/dist/cjs/structures/Node.js +73 -4
- package/dist/cjs/structures/Player.d.ts +15 -2
- package/dist/cjs/structures/Player.js +50 -11
- package/dist/cjs/structures/Queue.d.ts +1 -1
- package/dist/cjs/structures/Utils.d.ts +45 -2
- package/dist/cjs/structures/Utils.js +13 -0
- package/dist/esm/structures/CustomSearches/BandCampSearch.js +1 -0
- package/dist/esm/structures/LavalinkManager.d.ts +51 -12
- package/dist/esm/structures/LavalinkManager.js +21 -14
- package/dist/esm/structures/Node.d.ts +10 -1
- package/dist/esm/structures/Node.js +72 -3
- package/dist/esm/structures/Player.d.ts +15 -2
- package/dist/esm/structures/Player.js +50 -11
- package/dist/esm/structures/Queue.d.ts +1 -1
- package/dist/esm/structures/Utils.d.ts +45 -2
- package/dist/esm/structures/Utils.js +13 -0
- package/dist/types/structures/LavalinkManager.d.ts +51 -12
- package/dist/types/structures/Node.d.ts +10 -1
- package/dist/types/structures/Player.d.ts +15 -2
- package/dist/types/structures/Queue.d.ts +1 -1
- package/dist/types/structures/Utils.d.ts +45 -2
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { NodeManager } from "./NodeManager";
|
|
|
5
5
|
import { DestroyReasonsType, Player, PlayerJson, PlayerOptions } from "./Player";
|
|
6
6
|
import { ManagerQueueOptions } from "./Queue";
|
|
7
7
|
import { Track, UnresolvedTrack } from "./Track";
|
|
8
|
-
import { ChannelDeletePacket, GuildShardPayload, ManagerUtils, MiniMap, SearchPlatform, TrackEndEvent, TrackExceptionEvent, TrackStartEvent, TrackStuckEvent, VoicePacket, VoiceServer, VoiceState, WebSocketClosedEvent } from "./Utils";
|
|
8
|
+
import { ChannelDeletePacket, GuildShardPayload, ManagerUtils, MiniMap, SearchPlatform, SponsorBlockChaptersLoaded, SponsorBlockChapterStarted, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, TrackEndEvent, TrackExceptionEvent, TrackStartEvent, TrackStuckEvent, VoicePacket, VoiceServer, VoiceState, WebSocketClosedEvent } from "./Utils";
|
|
9
9
|
export interface LavalinkManager {
|
|
10
10
|
nodeManager: NodeManager;
|
|
11
11
|
utils: ManagerUtils;
|
|
@@ -33,7 +33,7 @@ export interface ManagerPlayerOptions {
|
|
|
33
33
|
onDisconnect?: {
|
|
34
34
|
/** Try to reconnect? -> If fails -> Destroy */
|
|
35
35
|
autoReconnect?: boolean;
|
|
36
|
-
/** Instantly destroy player (overrides autoReconnect) */
|
|
36
|
+
/** Instantly destroy player (overrides autoReconnect) | Don't provide == disable feature*/
|
|
37
37
|
destroyPlayer?: boolean;
|
|
38
38
|
};
|
|
39
39
|
onEmptyQueue?: {
|
|
@@ -56,16 +56,27 @@ export interface ManagerOptions {
|
|
|
56
56
|
playerOptions?: ManagerPlayerOptions;
|
|
57
57
|
/** If it should skip to the next Track on TrackEnd / TrackError etc. events */
|
|
58
58
|
autoSkip?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
/** If it should emit only new (unique) songs and not when a looping track (or similar) is plaid, default false */
|
|
60
|
+
emitNewSongsOnly?: boolean;
|
|
61
|
+
/** Only allow link requests with links either matching some of that regExp or including some of that string */
|
|
62
|
+
linksWhitelist?: (RegExp | string)[];
|
|
63
|
+
/** 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) */
|
|
64
|
+
linksBlacklist?: (RegExp | string)[];
|
|
65
|
+
/** If links should be allowed or not. If set to false, it will throw an error if a link was provided. */
|
|
66
|
+
linksAllowed?: boolean;
|
|
67
|
+
/** Advanced Options for the Library, which may or may not be "library breaking" */
|
|
68
|
+
advancedOptions?: {
|
|
69
|
+
/** optional */
|
|
70
|
+
debugOptions?: {
|
|
71
|
+
/** logs for debugging the "no-Audio" playing error */
|
|
72
|
+
noAudio?: boolean;
|
|
73
|
+
/** For Logging the Destroy function */
|
|
74
|
+
playerDestroy?: {
|
|
75
|
+
/** To show the debug reason at all times. */
|
|
76
|
+
debugLog?: boolean;
|
|
77
|
+
/** If you get 'Error: Use Player#destroy("reason") not LavalinkManager#deletePlayer() to stop the Player' put it on true */
|
|
78
|
+
dontThrowError?: boolean;
|
|
79
|
+
};
|
|
69
80
|
};
|
|
70
81
|
};
|
|
71
82
|
}
|
|
@@ -125,6 +136,34 @@ interface LavalinkManagerEvents {
|
|
|
125
136
|
* @event Manager#playerUpdate
|
|
126
137
|
*/
|
|
127
138
|
"playerUpdate": (oldPlayerJson: PlayerJson, newPlayer: Player) => void;
|
|
139
|
+
/**
|
|
140
|
+
* SPONSORBLOCK-PLUGIN EVENT
|
|
141
|
+
* Emitted when Segments are loaded
|
|
142
|
+
* @link https://github.com/topi314/Sponsorblock-Plugin#segmentsloaded
|
|
143
|
+
* @event Manager#trackError
|
|
144
|
+
*/
|
|
145
|
+
"SegmentsLoaded": (player: Player, track: Track | UnresolvedTrack, payload: SponsorBlockSegmentsLoaded) => void;
|
|
146
|
+
/**
|
|
147
|
+
* SPONSORBLOCK-PLUGIN EVENT
|
|
148
|
+
* Emitted when a specific Segment was skipped
|
|
149
|
+
* @link https://github.com/topi314/Sponsorblock-Plugin#segmentskipped
|
|
150
|
+
* @event Manager#trackError
|
|
151
|
+
*/
|
|
152
|
+
"SegmentSkipped": (player: Player, track: Track | UnresolvedTrack, payload: SponsorBlockSegmentSkipped) => void;
|
|
153
|
+
/**
|
|
154
|
+
* SPONSORBLOCK-PLUGIN EVENT
|
|
155
|
+
* Emitted when a specific Chapter starts playing
|
|
156
|
+
* @link https://github.com/topi314/Sponsorblock-Plugin#chapterstarted
|
|
157
|
+
* @event Manager#trackError
|
|
158
|
+
*/
|
|
159
|
+
"ChapterStarted": (player: Player, track: Track | UnresolvedTrack, payload: SponsorBlockChapterStarted) => void;
|
|
160
|
+
/**
|
|
161
|
+
* SPONSORBLOCK-PLUGIN EVENT
|
|
162
|
+
* Emitted when Chapters are loaded
|
|
163
|
+
* @link https://github.com/topi314/Sponsorblock-Plugin#chaptersloaded
|
|
164
|
+
* @event Manager#trackError
|
|
165
|
+
*/
|
|
166
|
+
"ChaptersLoaded": (player: Player, track: Track | UnresolvedTrack, payload: SponsorBlockChaptersLoaded) => void;
|
|
128
167
|
}
|
|
129
168
|
export interface LavalinkManager {
|
|
130
169
|
options: ManagerOptions;
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
import internal from "stream";
|
|
3
3
|
import { Dispatcher, Pool } from "undici";
|
|
4
4
|
import { NodeManager } from "./NodeManager";
|
|
5
|
-
import { DestroyReasonsType } from "./Player";
|
|
5
|
+
import { DestroyReasonsType, Player } from "./Player";
|
|
6
6
|
import { Track } from "./Track";
|
|
7
7
|
import { Base64, InvalidLavalinkRestRequest, LavalinkPlayer, LavaSearchQuery, LavaSearchResponse, PlayerUpdateInfo, RoutePlanner, SearchQuery, SearchResult, Session } from "./Utils";
|
|
8
8
|
/** Modifies any outgoing REST requests. */
|
|
9
9
|
export type ModifyRequest = (options: Dispatcher.RequestOptions) => void;
|
|
10
|
+
export declare const validSponsorBlocks: string[];
|
|
11
|
+
export type SponsorBlockSegment = "sponsor" | "selfpromo" | "interaction" | "intro" | "outro" | "preview" | "music_offtopic" | "filler";
|
|
10
12
|
export interface LavalinkNodeOptions {
|
|
11
13
|
/** The Lavalink Server-Ip / Domain-URL */
|
|
12
14
|
host: string;
|
|
@@ -238,8 +240,15 @@ export declare class LavalinkNode {
|
|
|
238
240
|
private error;
|
|
239
241
|
private message;
|
|
240
242
|
private handleEvent;
|
|
243
|
+
private SponsorBlockSegmentLoaded;
|
|
244
|
+
private SponsorBlockSegmentkipped;
|
|
245
|
+
private SponsorBlockChaptersLoaded;
|
|
246
|
+
private SponsorBlockChapterStarted;
|
|
241
247
|
private trackStart;
|
|
242
248
|
private trackEnd;
|
|
249
|
+
getSponsorBlock(player: Player): Promise<SponsorBlockSegment[]>;
|
|
250
|
+
setSponsorBlock(player: Player, segments?: SponsorBlockSegment[]): Promise<void>;
|
|
251
|
+
deleteSponsorBlock(player: Player): Promise<void>;
|
|
243
252
|
private queueEnd;
|
|
244
253
|
private trackStuck;
|
|
245
254
|
private trackError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EQBand, FilterData, FilterManager, LavalinkFilterData } from "./Filters";
|
|
2
2
|
import { LavalinkManager } from "./LavalinkManager";
|
|
3
|
-
import { LavalinkNode } from "./Node";
|
|
3
|
+
import { LavalinkNode, SponsorBlockSegment } from "./Node";
|
|
4
4
|
import { Queue } from "./Queue";
|
|
5
5
|
import { Track, UnresolvedTrack } from "./Track";
|
|
6
6
|
import { LavalinkPlayerVoiceOptions, LavaSearchQuery, SearchQuery } from "./Utils";
|
|
@@ -149,6 +149,9 @@ export declare class Player {
|
|
|
149
149
|
*/
|
|
150
150
|
setVolume(volume: number, ignoreVolumeDecrementer?: boolean): Promise<this>;
|
|
151
151
|
lavaSearch(query: LavaSearchQuery, requestUser: unknown): Promise<import("./Utils").SearchResult | import("./Utils").LavaSearchResponse>;
|
|
152
|
+
setSponsorBlock(segments?: SponsorBlockSegment[]): Promise<void>;
|
|
153
|
+
getSponsorBlock(): Promise<SponsorBlockSegment[]>;
|
|
154
|
+
deleteSponsorBlock(): Promise<void>;
|
|
152
155
|
/**
|
|
153
156
|
*
|
|
154
157
|
* @param query Query for your data
|
|
@@ -177,12 +180,22 @@ export declare class Player {
|
|
|
177
180
|
* Skip the current song, or a specific amount of songs
|
|
178
181
|
* @param amount provide the index of the next track to skip to
|
|
179
182
|
*/
|
|
180
|
-
skip(skipTo?: number): Promise<any>;
|
|
183
|
+
skip(skipTo?: number, throwError?: boolean): Promise<any>;
|
|
184
|
+
/**
|
|
185
|
+
* Clears the queue and stops playing. Does not destroy the Player and not leave the channel
|
|
186
|
+
* @returns
|
|
187
|
+
*/
|
|
188
|
+
stopPlaying(): Promise<this>;
|
|
181
189
|
/**
|
|
182
190
|
* Connects the Player to the Voice Channel
|
|
183
191
|
* @returns
|
|
184
192
|
*/
|
|
185
193
|
connect(): Promise<this>;
|
|
194
|
+
changeVoiceState(data: {
|
|
195
|
+
voiceChannelId?: string;
|
|
196
|
+
selfDeaf?: boolean;
|
|
197
|
+
selfMute?: boolean;
|
|
198
|
+
}): Promise<this>;
|
|
186
199
|
/**
|
|
187
200
|
* Disconnects the Player from the Voice Channel, but keeps the player in the cache
|
|
188
201
|
* @param force If false it throws an error, if player thinks it's already disconnected
|
|
@@ -18,7 +18,7 @@ export interface QueueStoreManager extends Record<string, any> {
|
|
|
18
18
|
parse: (value: unknown) => Promise<Partial<StoredQueue>>;
|
|
19
19
|
}
|
|
20
20
|
export interface ManagerQueueOptions {
|
|
21
|
-
/** Maximum Amount of tracks for the queue.previous array */
|
|
21
|
+
/** Maximum Amount of tracks for the queue.previous array. Set to 0 to not save previous songs. Defaults to 25 Tracks */
|
|
22
22
|
maxPreviousTracks?: number;
|
|
23
23
|
/** Custom Queue Store option */
|
|
24
24
|
queueStore?: QueueStoreManager;
|
|
@@ -152,7 +152,7 @@ export declare class MiniMap<K, V> extends Map<K, V> {
|
|
|
152
152
|
map<T>(fn: (value: V, key: K, miniMap: this) => T): T[];
|
|
153
153
|
map<This, T>(fn: (this: This, value: V, key: K, miniMap: this) => T, thisArg: This): T[];
|
|
154
154
|
}
|
|
155
|
-
export type PlayerEvents = TrackStartEvent | TrackEndEvent | TrackStuckEvent | TrackExceptionEvent | WebSocketClosedEvent;
|
|
155
|
+
export type PlayerEvents = TrackStartEvent | TrackEndEvent | TrackStuckEvent | TrackExceptionEvent | WebSocketClosedEvent | SponsorBlockSegmentEvents;
|
|
156
156
|
export type Severity = "COMMON" | "SUSPICIOUS" | "FAULT";
|
|
157
157
|
export interface Exception {
|
|
158
158
|
severity: Severity;
|
|
@@ -188,9 +188,52 @@ export interface WebSocketClosedEvent extends PlayerEvent {
|
|
|
188
188
|
byRemote: boolean;
|
|
189
189
|
reason: string;
|
|
190
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Types & Events for Sponsorblock-plugin from Lavalink: https://github.com/topi314/Sponsorblock-Plugin#segmentsloaded
|
|
193
|
+
*/
|
|
194
|
+
export type SponsorBlockSegmentEvents = SponsorBlockSegmentSkipped | SponsorBlockSegmentsLoaded | SponsorBlockChapterStarted | SponsorBlockChaptersLoaded;
|
|
195
|
+
export type SponsorBlockSegmentEventType = "SegmentSkipped" | "SegmentsLoaded" | "ChaptersLoaded" | "ChapterStarted";
|
|
196
|
+
export interface SponsorBlockSegmentsLoaded extends PlayerEvent {
|
|
197
|
+
type: "SegmentsLoaded";
|
|
198
|
+
segments: {
|
|
199
|
+
category: string;
|
|
200
|
+
start: number;
|
|
201
|
+
end: number;
|
|
202
|
+
}[];
|
|
203
|
+
}
|
|
204
|
+
export interface SponsorBlockSegmentSkipped extends PlayerEvent {
|
|
205
|
+
type: "SegmentSkipped";
|
|
206
|
+
segment: {
|
|
207
|
+
category: string;
|
|
208
|
+
start: number;
|
|
209
|
+
end: number;
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
export interface SponsorBlockChapterStarted extends PlayerEvent {
|
|
213
|
+
type: "ChapterStarted";
|
|
214
|
+
/** The Chapter which started */
|
|
215
|
+
chapter: {
|
|
216
|
+
/** The Name of the Chapter */
|
|
217
|
+
name: string;
|
|
218
|
+
start: number;
|
|
219
|
+
end: number;
|
|
220
|
+
duration: number;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
export interface SponsorBlockChaptersLoaded extends PlayerEvent {
|
|
224
|
+
type: "ChaptersLoaded";
|
|
225
|
+
/** All Chapters loaded */
|
|
226
|
+
chapters: {
|
|
227
|
+
/** The Name of the Chapter */
|
|
228
|
+
name: string;
|
|
229
|
+
start: number;
|
|
230
|
+
end: number;
|
|
231
|
+
duration: number;
|
|
232
|
+
}[];
|
|
233
|
+
}
|
|
191
234
|
export type LoadTypes = "track" | "playlist" | "search" | "error" | "empty";
|
|
192
235
|
export type State = "CONNECTED" | "CONNECTING" | "DISCONNECTED" | "DISCONNECTING" | "DESTROYING";
|
|
193
|
-
export type PlayerEventType = "TrackStartEvent" | "TrackEndEvent" | "TrackExceptionEvent" | "TrackStuckEvent" | "WebSocketClosedEvent";
|
|
236
|
+
export type PlayerEventType = "TrackStartEvent" | "TrackEndEvent" | "TrackExceptionEvent" | "TrackStuckEvent" | "WebSocketClosedEvent" | SponsorBlockSegmentEventType;
|
|
194
237
|
export type TrackEndReason = "finished" | "loadFailed" | "stopped" | "replaced" | "cleanup";
|
|
195
238
|
export interface InvalidLavalinkRestRequest {
|
|
196
239
|
timestamp: number;
|
package/package.json
CHANGED