lavalink-client 2.3.3 → 2.3.5

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.
Files changed (60) hide show
  1. package/README.md +211 -24
  2. package/dist/cjs/index.d.ts +16 -16
  3. package/dist/cjs/index.js +16 -16
  4. package/dist/cjs/package.json +3 -0
  5. package/dist/cjs/structures/Constants.d.ts +2 -1
  6. package/dist/cjs/structures/Constants.js +1 -0
  7. package/dist/cjs/structures/CustomSearches/BandCampSearch.d.ts +2 -2
  8. package/dist/cjs/structures/Filters.d.ts +2 -2
  9. package/dist/cjs/structures/Filters.js +1 -1
  10. package/dist/cjs/structures/LavalinkManager.d.ts +6 -6
  11. package/dist/cjs/structures/LavalinkManager.js +5 -5
  12. package/dist/cjs/structures/LavalinkManagerStatics.d.ts +1 -1
  13. package/dist/cjs/structures/Node.d.ts +6 -6
  14. package/dist/cjs/structures/Node.js +10 -3
  15. package/dist/cjs/structures/NodeManager.d.ts +5 -5
  16. package/dist/cjs/structures/NodeManager.js +5 -5
  17. package/dist/cjs/structures/Player.d.ts +10 -10
  18. package/dist/cjs/structures/Player.js +37 -14
  19. package/dist/cjs/structures/Queue.d.ts +3 -3
  20. package/dist/cjs/structures/Queue.js +1 -1
  21. package/dist/cjs/structures/Types/Filters.d.ts +1 -1
  22. package/dist/cjs/structures/Types/Manager.d.ts +7 -7
  23. package/dist/cjs/structures/Types/Node.d.ts +3 -3
  24. package/dist/cjs/structures/Types/Player.d.ts +5 -5
  25. package/dist/cjs/structures/Types/Queue.d.ts +1 -1
  26. package/dist/cjs/structures/Types/Track.d.ts +3 -3
  27. package/dist/cjs/structures/Types/Utils.d.ts +5 -5
  28. package/dist/cjs/structures/Utils.d.ts +6 -6
  29. package/dist/cjs/structures/Utils.js +23 -7
  30. package/dist/esm/index.d.ts +16 -16
  31. package/dist/esm/index.js +16 -16
  32. package/dist/esm/package.json +3 -0
  33. package/dist/esm/structures/Constants.d.ts +2 -1
  34. package/dist/esm/structures/Constants.js +1 -0
  35. package/dist/esm/structures/CustomSearches/BandCampSearch.d.ts +2 -2
  36. package/dist/esm/structures/Filters.d.ts +2 -2
  37. package/dist/esm/structures/Filters.js +1 -1
  38. package/dist/esm/structures/LavalinkManager.d.ts +6 -6
  39. package/dist/esm/structures/LavalinkManager.js +5 -5
  40. package/dist/esm/structures/LavalinkManagerStatics.d.ts +1 -1
  41. package/dist/esm/structures/Node.d.ts +6 -6
  42. package/dist/esm/structures/Node.js +10 -3
  43. package/dist/esm/structures/NodeManager.d.ts +5 -5
  44. package/dist/esm/structures/NodeManager.js +4 -4
  45. package/dist/esm/structures/Player.d.ts +10 -10
  46. package/dist/esm/structures/Player.js +37 -14
  47. package/dist/esm/structures/Queue.d.ts +3 -3
  48. package/dist/esm/structures/Queue.js +1 -1
  49. package/dist/esm/structures/Types/Filters.d.ts +1 -1
  50. package/dist/esm/structures/Types/Manager.d.ts +7 -7
  51. package/dist/esm/structures/Types/Node.d.ts +3 -3
  52. package/dist/esm/structures/Types/Player.d.ts +5 -5
  53. package/dist/esm/structures/Types/Queue.d.ts +1 -1
  54. package/dist/esm/structures/Types/Track.d.ts +3 -3
  55. package/dist/esm/structures/Types/Utils.d.ts +5 -5
  56. package/dist/esm/structures/Utils.d.ts +6 -6
  57. package/dist/esm/structures/Utils.js +23 -7
  58. package/dist/types/structures/Constants.d.ts +1 -0
  59. package/dist/types/structures/NodeManager.d.ts +1 -1
  60. package/package.json +13 -6
package/README.md CHANGED
@@ -106,6 +106,198 @@ Check out the [Documentation](https://lc4.gitbook.io/lavalink-client) | or the [
106
106
 
107
107
  ***
108
108
 
109
+ # Sample Configuration
110
+
111
+
112
+ <details><summary>Complete Configuration Example, with all available options</summary>
113
+
114
+ ```ts
115
+ import { LavalinkManager, QueueChangesWatcher, QueueStoreManager } from "lavalink-client";
116
+ import { RedisClientType } from "redis"; // example for custom queue store
117
+ import { Client, GatewayIntentBits } from "discord.js"; // example for a discord bot
118
+
119
+ // you might want to extend the types of the client, to bind lavalink to it.
120
+ const client = new Client({
121
+ intents: [
122
+ GatewayIntentBits.Guilds,
123
+ GatewayIntentBits.GuildVoiceStates,
124
+ ]
125
+ });
126
+
127
+ const previouslyUsedSessions = new Map<string, string>(); //nodeManager.on("connect", node => previouslyUsedSessions.set(node.id, node.sessionId))
128
+
129
+ client.lavalink = new LavalinkManager({
130
+ nodes: [
131
+ {
132
+ authorization: "localhoist",
133
+ host: "localhost",
134
+ port: 2333,
135
+ id: "testnode",
136
+ // get the previously used session, to restart with "resuming" enabled
137
+ sessionId: previouslyUsedSessions.get("testnode"),
138
+ requestSignalTimeoutMS: 3000,
139
+ closeOnError: true,
140
+ heartBeatInterval: 30_000,
141
+ enablePingOnStatsCheck: true,
142
+ retryDelay: 10e3,
143
+ secure: false,
144
+ retryAmount: 5,
145
+ }
146
+ ],
147
+ sendToShard: (guildId, payload) => client.guilds.cache.get(guildId)?.shard?.send(payload),
148
+ autoSkip: true,
149
+ client: { // client: client.user
150
+ id: envConfig.clientId, // REQUIRED! (at least after the .init)
151
+ username: "TESTBOT",
152
+ },
153
+ autoSkipOnResolveError: true, // skip song, if resolving an unresolved song fails
154
+ emitNewSongsOnly: true, // don't emit "looping songs"
155
+ playerOptions: {
156
+ // These are the default prevention methods
157
+ maxErrorsPerTime: {
158
+ threshold: 10_000,
159
+ maxAmount: 3,
160
+ },
161
+ // only allow an autoplay function to execute, if the previous function was longer ago than this number.
162
+ minAutoPlayMs: 10_000,
163
+
164
+ applyVolumeAsFilter: false,
165
+ clientBasedPositionUpdateInterval: 50, // in ms to up-calc player.position
166
+ defaultSearchPlatform: "ytmsearch",
167
+ volumeDecrementer: 0.75, // on client 100% == on lavalink 75%
168
+ requesterTransformer: requesterTransformer,
169
+ onDisconnect: {
170
+ autoReconnect: true, // automatically attempts a reconnect, if the bot disconnects from the voice channel, if it fails, it get's destroyed
171
+ destroyPlayer: false // overrides autoReconnect and directly destroys the player if the bot disconnects from the vc
172
+ },
173
+ onEmptyQueue: {
174
+ destroyAfterMs: 30_000, // 0 === instantly destroy | don't provide the option, to don't destroy the player
175
+ autoPlayFunction: autoPlayFunction,
176
+ },
177
+ useUnresolvedData: true,
178
+ },
179
+ queueOptions: {
180
+ maxPreviousTracks: 10,
181
+ // only needed if you want and need external storage, don't provide if you don't need to
182
+ queueStore: new myCustomStore(client.redis), // client.redis = new redis()
183
+ // only needed, if you want to watch changes in the queue via a custom class,
184
+ queueChangesWatcher: new myCustomWatcher(client)
185
+ },
186
+ linksAllowed: true,
187
+ // example: don't allow p*rn / youtube links., you can also use a regex pattern if you want.
188
+ // linksBlacklist: ["porn", "youtube.com", "youtu.be"],
189
+ linksBlacklist: [],
190
+ linksWhitelist: [],
191
+ advancedOptions: {
192
+ enableDebugEvents: true,
193
+ maxFilterFixDuration: 600_000, // only allow instafixfilterupdate for tracks sub 10mins
194
+ debugOptions: {
195
+ noAudio: false,
196
+ playerDestroy: {
197
+ dontThrowError: false,
198
+ debugLog: false,
199
+ },
200
+ logCustomSearches: false,
201
+ }
202
+ }
203
+ });
204
+
205
+
206
+ client.on("raw", d => client.lavalink.sendRawData(d)); // send raw data to lavalink-client to handle stuff
207
+
208
+ client.on("ready", () => {
209
+ client.lavalink.init(client.user); // init lavalink
210
+ });
211
+
212
+ // for the custom queue Store create a redis instance
213
+ client.redis = createClient({ url: "redis://localhost:6379", password: "securepass" });
214
+ client.redis.connect();
215
+
216
+
217
+ // Custom external queue Store
218
+ export class myCustomStore implements QueueStoreManager {
219
+ private redis:RedisClientType;
220
+ constructor(redisClient:RedisClientType) {
221
+ this.redis = redisClient;
222
+ }
223
+ async get(guildId): Promise<any> {
224
+ return await this.redis.get(this.id(guildId));
225
+ }
226
+ async set(guildId, stringifiedQueueData): Promise<any> {
227
+ return await this.redis.set(this.id(guildId), stringifiedQueueData);
228
+ }
229
+ async delete(guildId): Promise<any> {
230
+ return await this.redis.del(this.id(guildId));
231
+ }
232
+ async parse(stringifiedQueueData): Promise<Partial<StoredQueue>> {
233
+ return JSON.parse(stringifiedQueueData);
234
+ }
235
+ async stringify(parsedQueueData): Promise<any> {
236
+ return JSON.stringify(parsedQueueData);
237
+ }
238
+ private id(guildId) {
239
+ return `lavalinkqueue_${guildId}`; // transform the id to your belikings
240
+ }
241
+ }
242
+
243
+ // Custom Queue Watcher Functions
244
+ export class myCustomWatcher implements QueueChangesWatcher {
245
+ constructor() {
246
+ }
247
+ shuffled(guildId, oldStoredQueue, newStoredQueue) {
248
+ console.log(`${this.client.guilds.cache.get(guildId)?.name || guildId}: Queue got shuffled`)
249
+ }
250
+ tracksAdd(guildId, tracks, position, oldStoredQueue, newStoredQueue) {
251
+ console.log(`${this.client.guilds.cache.get(guildId)?.name || guildId}: ${tracks.length} Tracks got added into the Queue at position #${position}`);
252
+ }
253
+ tracksRemoved(guildId, tracks, position, oldStoredQueue, newStoredQueue) {
254
+ console.log(`${this.client.guilds.cache.get(guildId)?.name || guildId}: ${tracks.length} Tracks got removed from the Queue at position #${position}`);
255
+ }
256
+ }
257
+ ```
258
+
259
+ </details>
260
+
261
+
262
+
263
+ ```ts
264
+ import { LavalinkManager } from "lavalink-client";
265
+ import { Client, GatewayIntentBits } from "discord.js"; // example for a discord bot
266
+
267
+ // you might want to extend the types of the client, to bind lavalink to it.
268
+ const client = new Client({
269
+ intents: [
270
+ GatewayIntentBits.Guilds,
271
+ GatewayIntentBits.GuildVoiceStates,
272
+ ]
273
+ });
274
+
275
+ // create instance
276
+ client.lavalink = new LavalinkManager({
277
+ nodes: [
278
+ {
279
+ authorization: "localhoist",
280
+ host: "localhost",
281
+ port: 2333,
282
+ id: "testnode",
283
+ }
284
+ ],
285
+ sendToShard: (guildId, payload) => client.guilds.cache.get(guildId)?.shard?.send(payload),
286
+ autoSkip: true,
287
+ client: {
288
+ id: envConfig.clientId,
289
+ username: "TESTBOT",
290
+ },
291
+ });
292
+
293
+ client.on("raw", d => client.lavalink.sendRawData(d)); // send raw data to lavalink-client to handle stuff
294
+
295
+ client.on("ready", () => {
296
+ client.lavalink.init(client.user); // init lavalink
297
+ });
298
+
299
+ ```
300
+
109
301
  # All Events:
110
302
 
111
303
  ## On **Lavalink-Manager**:
@@ -189,28 +381,10 @@ client.lavalink = new LavalinkManager({
189
381
 
190
382
  ## How to do resuming
191
383
 
192
- ```js
193
- // 1. while the player is playing, make sure to enable it:
194
- const durationToKeepPlayingInMS = 600_000;
195
- await player.node.updateSession(true, durationToKeepPlayingInMS);
196
- ```
197
-
198
- ```js
199
- // 2. make sure to have an eventlistener for resuming events somewhere
200
- client.lavalink.nodeManager.on("resumed", (node, payload, fetchedPlayers) => {
201
- // create players:
202
- for(const fetchedPlayer of fetchedPlayers) {
203
- const player = client.lavalink.createPlayer({
204
- guildId: fetchedPlayer.guildId,
205
- });
206
- player.setVolume(fetchedPlayer.volume);
207
- // and apply other things (e.g. paused, voice, filters, state, ...) (stuff like vc channel, text channel you need to store somewhere)
208
- await player.queue.utils.sync(); // only works with a queuestore
209
- // you can now overwride the player.queue.current track from the fetchedPlayer, or use the one from the queue.uztils.sync function
210
- // continue with your resuming code...
211
- }
212
- })
213
- ```
384
+ 1. You need to enable resuming on a __connected__ Lavalink node : **` node.updateSession(true, 360e3) `**
385
+ 2. The NodeManager#resumed event will emit when the node resumes, you retrieves all fetchedPlayers (fetched by the client), and thus all you need to do is re-create all player instances (and possibly the queues too)
386
+ - For that is the queuestore useful
387
+ - To save the playerData you can utilize smt like playerUpdate event.
214
388
 
215
389
  ## Resuming full Example
216
390
  Full code sample: can be found on the [Testbot in here](https://github.com/Tomato6966/lavalink-client/blob/main/testBot/Utils/handleResuming.ts)
@@ -511,7 +685,7 @@ if(previousTrack) {
511
685
  - Fixed Export, where types of Manager weren't exported correctly
512
686
  - Fixed Dist Folder containing old, left over not needed files
513
687
 
514
- ## **Version 2.3.2**
688
+ ## **Version 2.3.2** / **Version 2.3.3**
515
689
  - Added Missing function calls for the QueueWatcher of tracksRemoved within the queue.remove() function:
516
690
  - Added new DestroyReasons:
517
691
  - TrackStuckMaxTracksErroredPerTime
@@ -534,4 +708,17 @@ if(previousTrack) {
534
708
  - The **` functionLayer `** string will show you where the debug event was triggered from
535
709
  - The **` message `** string will show what is debugged
536
710
  - The **` error `** object will show you the error that happened, if there was one.
537
- - *This took quite some time to code, and i am sure there are still many logs you might want, feel free to open an issue or commit with an PR, if you think something is missing!*
711
+ - *This took quite some time to code, and i am sure there are still many logs you might want, feel free to open an issue
712
+
713
+
714
+ ## **Version 2.3.4**
715
+ - Improved the package bundling with tsc-alias, to export files with file types
716
+ - Added package.json to exported dist, for easier parsing ability and compatibility with older and newer node versions
717
+ - Added error handling for resolving unresolved tracks on trackend
718
+
719
+
720
+ ## **Version 2.3.5**
721
+ - FIXED not able to import :: Accidentally removed tsc-alias configuration, which made importing not work
722
+ - FIXED autoplay not working :: Accidentally added an invalid if statement, which made autoplay not working anymore (during the if statement to not prevent autoplay spam)
723
+ - Added a new AutoplayExecution Debug Log
724
+ - Added more samples to the Testbot related configuration
@@ -1,16 +1,16 @@
1
- export * from "./structures/LavalinkManager";
2
- export * from "./structures/Filters";
3
- export * from "./structures/LavalinkManagerStatics";
4
- export * from "./structures/Node";
5
- export * from "./structures/NodeManager";
6
- export * from "./structures/Player";
7
- export * from "./structures/Queue";
8
- export * from "./structures/Utils";
9
- export * from "./structures/Types/Track";
10
- export * from "./structures/Types/Utils";
11
- export * from "./structures/Types/Filters";
12
- export * from "./structures/Types/Player";
13
- export * from "./structures/Types/Queue";
14
- export * from "./structures/Types/Node";
15
- export * from "./structures/Constants";
16
- export * from "./structures/Types/Manager";
1
+ export * from "./structures/LavalinkManager.js";
2
+ export * from "./structures/Filters.js";
3
+ export * from "./structures/LavalinkManagerStatics.js";
4
+ export * from "./structures/Node.js";
5
+ export * from "./structures/NodeManager.js";
6
+ export * from "./structures/Player.js";
7
+ export * from "./structures/Queue.js";
8
+ export * from "./structures/Utils.js";
9
+ export * from "./structures/Types/Track.js";
10
+ export * from "./structures/Types/Utils.js";
11
+ export * from "./structures/Types/Filters.js";
12
+ export * from "./structures/Types/Player.js";
13
+ export * from "./structures/Types/Queue.js";
14
+ export * from "./structures/Types/Node.js";
15
+ export * from "./structures/Constants.js";
16
+ export * from "./structures/Types/Manager.js";
package/dist/cjs/index.js CHANGED
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./structures/LavalinkManager"), exports);
5
- tslib_1.__exportStar(require("./structures/Filters"), exports);
6
- tslib_1.__exportStar(require("./structures/LavalinkManagerStatics"), exports);
7
- tslib_1.__exportStar(require("./structures/Node"), exports);
8
- tslib_1.__exportStar(require("./structures/NodeManager"), exports);
9
- tslib_1.__exportStar(require("./structures/Player"), exports);
10
- tslib_1.__exportStar(require("./structures/Queue"), exports);
11
- tslib_1.__exportStar(require("./structures/Utils"), exports);
12
- tslib_1.__exportStar(require("./structures/Types/Track"), exports);
13
- tslib_1.__exportStar(require("./structures/Types/Utils"), exports);
14
- tslib_1.__exportStar(require("./structures/Types/Filters"), exports);
15
- tslib_1.__exportStar(require("./structures/Types/Player"), exports);
16
- tslib_1.__exportStar(require("./structures/Types/Queue"), exports);
17
- tslib_1.__exportStar(require("./structures/Types/Node"), exports);
18
- tslib_1.__exportStar(require("./structures/Constants"), exports);
19
- tslib_1.__exportStar(require("./structures/Types/Manager"), exports);
4
+ tslib_1.__exportStar(require("./structures/LavalinkManager.js"), exports);
5
+ tslib_1.__exportStar(require("./structures/Filters.js"), exports);
6
+ tslib_1.__exportStar(require("./structures/LavalinkManagerStatics.js"), exports);
7
+ tslib_1.__exportStar(require("./structures/Node.js"), exports);
8
+ tslib_1.__exportStar(require("./structures/NodeManager.js"), exports);
9
+ tslib_1.__exportStar(require("./structures/Player.js"), exports);
10
+ tslib_1.__exportStar(require("./structures/Queue.js"), exports);
11
+ tslib_1.__exportStar(require("./structures/Utils.js"), exports);
12
+ tslib_1.__exportStar(require("./structures/Types/Track.js"), exports);
13
+ tslib_1.__exportStar(require("./structures/Types/Utils.js"), exports);
14
+ tslib_1.__exportStar(require("./structures/Types/Filters.js"), exports);
15
+ tslib_1.__exportStar(require("./structures/Types/Player.js"), exports);
16
+ tslib_1.__exportStar(require("./structures/Types/Queue.js"), exports);
17
+ tslib_1.__exportStar(require("./structures/Types/Node.js"), exports);
18
+ tslib_1.__exportStar(require("./structures/Constants.js"), exports);
19
+ tslib_1.__exportStar(require("./structures/Types/Manager.js"), exports);
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -1,8 +1,9 @@
1
- import type { AudioOutputs, ChannelMixFilter, EQBand } from "./Types/Filters";
1
+ import type { AudioOutputs, ChannelMixFilter, EQBand } from "./Types/Filters.js";
2
2
  export declare enum DebugEvents {
3
3
  SetSponsorBlock = "SetSponsorBlock",
4
4
  DeleteSponsorBlock = "DeleteSponsorBlock",
5
5
  TrackEndReplaced = "TrackEndReplaced",
6
+ AutoplayExecution = "AutoplayExecution",
6
7
  AutoplayNoSongsAdded = "AutoplayNoSongsAdded",
7
8
  AutoplayThresholdSpamLimiter = "AutoplayThresholdSpamLimiter",
8
9
  TriggerQueueEmptyInterval = "TriggerQueueEmptyInterval",
@@ -6,6 +6,7 @@ var DebugEvents;
6
6
  DebugEvents["SetSponsorBlock"] = "SetSponsorBlock";
7
7
  DebugEvents["DeleteSponsorBlock"] = "DeleteSponsorBlock";
8
8
  DebugEvents["TrackEndReplaced"] = "TrackEndReplaced";
9
+ DebugEvents["AutoplayExecution"] = "AutoplayExecution";
9
10
  DebugEvents["AutoplayNoSongsAdded"] = "AutoplayNoSongsAdded";
10
11
  DebugEvents["AutoplayThresholdSpamLimiter"] = "AutoplayThresholdSpamLimiter";
11
12
  DebugEvents["TriggerQueueEmptyInterval"] = "TriggerQueueEmptyInterval";
@@ -1,3 +1,3 @@
1
- import type { Player } from "../Player";
2
- import type { UnresolvedSearchResult } from "../Types/Utils";
1
+ import type { Player } from "../Player.js";
2
+ import type { UnresolvedSearchResult } from "../Types/Utils.js";
3
3
  export declare const bandCampSearch: (player: Player, query: string, requestUser: unknown) => Promise<UnresolvedSearchResult>;
@@ -1,5 +1,5 @@
1
- import type { Player } from "./Player";
2
- import type { AudioOutputs, EQBand, FilterData, PlayerFilters, TimescaleFilter } from "./Types/Filters";
1
+ import type { Player } from "./Player.js";
2
+ import type { AudioOutputs, EQBand, FilterData, PlayerFilters, TimescaleFilter } from "./Types/Filters.js";
3
3
  /**
4
4
  * The FilterManager for each player
5
5
  */
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FilterManager = void 0;
4
- const Constants_1 = require("./Constants");
4
+ const Constants_1 = require("./Constants.js");
5
5
  /**
6
6
  * The FilterManager for each player
7
7
  */
@@ -1,11 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from "events";
3
- import { NodeManager } from "./NodeManager";
4
- import { Player } from "./Player";
5
- import { ManagerUtils, MiniMap } from "./Utils";
6
- import type { BotClientOptions, LavalinkManagerEvents, ManagerOptions } from "./Types/Manager";
7
- import type { PlayerOptions } from "./Types/Player";
8
- import type { ChannelDeletePacket, VoicePacket, VoiceServer, VoiceState } from "./Types/Utils";
3
+ import { NodeManager } from "./NodeManager.js";
4
+ import { Player } from "./Player.js";
5
+ import { ManagerUtils, MiniMap } from "./Utils.js";
6
+ import type { BotClientOptions, LavalinkManagerEvents, ManagerOptions } from "./Types/Manager.js";
7
+ import type { PlayerOptions } from "./Types/Player.js";
8
+ import type { ChannelDeletePacket, VoicePacket, VoiceServer, VoiceState } from "./Types/Utils.js";
9
9
  export declare class LavalinkManager extends EventEmitter {
10
10
  /**
11
11
  * Emit an event
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LavalinkManager = void 0;
4
4
  const events_1 = require("events");
5
- const Constants_1 = require("./Constants");
6
- const NodeManager_1 = require("./NodeManager");
7
- const Player_1 = require("./Player");
8
- const Queue_1 = require("./Queue");
9
- const Utils_1 = require("./Utils");
5
+ const Constants_1 = require("./Constants.js");
6
+ const NodeManager_1 = require("./NodeManager.js");
7
+ const Player_1 = require("./Player.js");
8
+ const Queue_1 = require("./Queue.js");
9
+ const Utils_1 = require("./Utils.js");
10
10
  class LavalinkManager extends events_1.EventEmitter {
11
11
  /**
12
12
  * Emit an event
@@ -1,4 +1,4 @@
1
- import type { ClientCustomSearchPlatformUtils, LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Types/Utils";
1
+ import type { ClientCustomSearchPlatformUtils, LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Types/Utils.js";
2
2
  /** Default Sources Record, to allow source parsing with multiple inputs. */
3
3
  export declare const DefaultSources: Record<SearchPlatform, LavalinkSearchPlatform | ClientCustomSearchPlatformUtils>;
4
4
  /** Lavalink Plugins definiton */
@@ -1,9 +1,9 @@
1
- import type { Player } from "./Player";
2
- import type { DestroyReasonsType } from "./Types/Player";
3
- import type { Track } from "./Types/Track";
4
- import type { Base64, InvalidLavalinkRestRequest, LavalinkPlayer, LavaSearchQuery, LavaSearchResponse, PlayerUpdateInfo, RoutePlanner, SearchQuery, SearchResult, Session } from "./Types/Utils";
5
- import type { NodeManager } from "./NodeManager";
6
- import type { BaseNodeStats, LavalinkInfo, LavalinkNodeOptions, ModifyRequest, NodeStats, SponsorBlockSegment } from "./Types/Node";
1
+ import type { Player } from "./Player.js";
2
+ import type { DestroyReasonsType } from "./Types/Player.js";
3
+ import type { Track } from "./Types/Track.js";
4
+ import type { Base64, InvalidLavalinkRestRequest, LavalinkPlayer, LavaSearchQuery, LavaSearchResponse, PlayerUpdateInfo, RoutePlanner, SearchQuery, SearchResult, Session } from "./Types/Utils.js";
5
+ import type { NodeManager } from "./NodeManager.js";
6
+ import type { BaseNodeStats, LavalinkInfo, LavalinkNodeOptions, ModifyRequest, NodeStats, SponsorBlockSegment } from "./Types/Node.js";
7
7
  /**
8
8
  * Lavalink Node creator class
9
9
  */
@@ -4,8 +4,8 @@ exports.LavalinkNode = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const path_1 = require("path");
6
6
  const ws_1 = tslib_1.__importDefault(require("ws"));
7
- const Constants_1 = require("./Constants");
8
- const Utils_1 = require("./Utils");
7
+ const Constants_1 = require("./Constants.js");
8
+ const Utils_1 = require("./Utils.js");
9
9
  /**
10
10
  * Lavalink Node creator class
11
11
  */
@@ -1256,9 +1256,16 @@ class LavalinkNode {
1256
1256
  });
1257
1257
  }
1258
1258
  if (typeof this.NodeManager.LavalinkManager.options?.playerOptions?.onEmptyQueue?.autoPlayFunction === "function" && typeof player.get("internal_autoplayStopPlaying") === "undefined") {
1259
+ if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
1260
+ this.NodeManager.LavalinkManager.emit("debug", Constants_1.DebugEvents.AutoplayExecution, {
1261
+ state: "log",
1262
+ message: `Now Triggering Autoplay.`,
1263
+ functionLayer: "LavalinkNode > queueEnd() > autoplayFunction",
1264
+ });
1265
+ }
1259
1266
  const previousAutoplayTime = player.get("internal_previousautoplay");
1260
1267
  const duration = previousAutoplayTime ? Date.now() - previousAutoplayTime : 0;
1261
- if ((duration && duration > this.NodeManager.LavalinkManager.options.playerOptions.minAutoPlayMs) || !!player.get("internal_skipped")) {
1268
+ if (!duration || duration > this.NodeManager.LavalinkManager.options.playerOptions.minAutoPlayMs || !!player.get("internal_skipped")) {
1262
1269
  await this.NodeManager.LavalinkManager.options?.playerOptions?.onEmptyQueue?.autoPlayFunction(player, track);
1263
1270
  player.set("internal_previousautoplay", Date.now());
1264
1271
  if (player.queue.tracks.length > 0)
@@ -1,9 +1,9 @@
1
1
  /// <reference types="node" />
2
- import { EventEmitter } from "stream";
3
- import { LavalinkNode } from "./Node";
4
- import { MiniMap } from "./Utils";
5
- import type { LavalinkNodeIdentifier, LavalinkNodeOptions, NodeManagerEvents } from "./Types/Node";
6
- import type { LavalinkManager } from "./LavalinkManager";
2
+ import { EventEmitter } from "events";
3
+ import { LavalinkNode } from "./Node.js";
4
+ import { MiniMap } from "./Utils.js";
5
+ import type { LavalinkNodeIdentifier, LavalinkNodeOptions, NodeManagerEvents } from "./Types/Node.js";
6
+ import type { LavalinkManager } from "./LavalinkManager.js";
7
7
  export declare class NodeManager extends EventEmitter {
8
8
  /**
9
9
  * Emit an event
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NodeManager = void 0;
4
- const stream_1 = require("stream");
5
- const Constants_1 = require("./Constants");
6
- const Node_1 = require("./Node");
7
- const Utils_1 = require("./Utils");
8
- class NodeManager extends stream_1.EventEmitter {
4
+ const events_1 = require("events");
5
+ const Constants_1 = require("./Constants.js");
6
+ const Node_1 = require("./Node.js");
7
+ const Utils_1 = require("./Utils.js");
8
+ class NodeManager extends events_1.EventEmitter {
9
9
  /**
10
10
  * Emit an event
11
11
  * @param event The event to emit
@@ -1,11 +1,11 @@
1
- import { FilterManager } from "./Filters";
2
- import { Queue } from "./Queue";
3
- import type { DestroyReasons } from "./Constants";
4
- import type { LavalinkNode } from "./Node";
5
- import type { SponsorBlockSegment } from "./Types/Node";
6
- import type { PlayerJson, PlayerOptions, PlayOptions, RepeatMode } from "./Types/Player";
7
- import type { LavalinkManager } from "./LavalinkManager";
8
- import type { LavalinkPlayerVoiceOptions, LavaSearchQuery, SearchQuery } from "./Types/Utils";
1
+ import { FilterManager } from "./Filters.js";
2
+ import { Queue } from "./Queue.js";
3
+ import type { DestroyReasons } from "./Constants.js";
4
+ import type { LavalinkNode } from "./Node.js";
5
+ import type { SponsorBlockSegment } from "./Types/Node.js";
6
+ import type { PlayerJson, PlayerOptions, PlayOptions, RepeatMode } from "./Types/Player.js";
7
+ import type { LavalinkManager } from "./LavalinkManager.js";
8
+ import type { LavalinkPlayerVoiceOptions, LavaSearchQuery, SearchQuery } from "./Types/Utils.js";
9
9
  export declare class Player {
10
10
  /** Filter Manager per player */
11
11
  filterManager: FilterManager;
@@ -96,7 +96,7 @@ export declare class Player {
96
96
  * @param throwOnEmpty If an error should be thrown if no track is found
97
97
  * @returns The search result
98
98
  */
99
- lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<import("./Types/Utils").SearchResult | import("./Types/Utils").LavaSearchResponse>;
99
+ lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<import("./Types/Utils.js").SearchResult | import("./Types/Utils.js").LavaSearchResponse>;
100
100
  /**
101
101
  * Set the SponsorBlock
102
102
  * @param segments The segments to set
@@ -115,7 +115,7 @@ export declare class Player {
115
115
  * @param query Query for your data
116
116
  * @param requestUser
117
117
  */
118
- search(query: SearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<import("./Types/Utils").UnresolvedSearchResult | import("./Types/Utils").SearchResult>;
118
+ search(query: SearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<import("./Types/Utils.js").UnresolvedSearchResult | import("./Types/Utils.js").SearchResult>;
119
119
  /**
120
120
  * Pause the player
121
121
  */