### Basic Lavalink Client Setup with Discord.js Source: https://tomato6966.github.io/lavalink-client/index A minimal example to quickly get started with lavalink-client and discord.js. It initializes the LavalinkManager and sets up event listeners for the Discord client. ```typescript import { LavalinkManager } from "lavalink-client"; import { Client, GatewayIntentBits } from "discord.js"; // example for a discord bot // Extend the Client type to include the lavalink manager declare module "discord.js" { interface Client { lavalink: LavalinkManager; } } const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates], }); client.lavalink = new LavalinkManager({ nodes: [ { authorization: "youshallnotpass", // The password for your Lavalink server host: "localhost", port: 2333, id: "Main Node", }, ], // A function to send voice server updates to the Lavalink client sendToShard: (guildId, payload) => { const guild = client.guilds.cache.get(guildId); if (guild) guild.shard.send(payload); }, autoSkip: true, client: { id: process.env.CLIENT_ID, // Your bot's user ID username: "MyBot", }, }); // Listen for the 'raw' event from discord.js and forward it client.on("raw", (d) => client.lavalink.sendRawData(d)); client.on("ready", () => { console.log(`Logged in as ${client.user.tag}!`); // Initialize the Lavalink client client.lavalink.init({ ...client.user }); }); client.login(process.env.DISCORD_TOKEN); ``` -------------------------------- ### Implement Custom Queue Changes Watcher Source: https://tomato6966.github.io/lavalink-client/home/example This example defines a custom class `myCustomWatcher` that implements the `QueueChangesWatcher` interface. It logs events such as queue shuffling, tracks being added, and tracks being removed, providing feedback on queue modifications within a specific guild. ```typescript import { QueueChangesWatcher, LavalinkManager } from "lavalink-client"; class myCustomWatcher implements QueueChangesWatcher { constructor(client) { this.client = client; } shuffled(guildId, oldStoredQueue, newStoredQueue) { console.log(`${this.client.guilds.cache.get(guildId)?.name || guildId}: Queue got shuffled`); } tracksAdd(guildId, tracks, position, oldStoredQueue, newStoredQueue) { console.log( `${this.client.guilds.cache.get(guildId)?.name || guildId}: ${tracks.length} Tracks got added into the Queue at position #${position}`, ); } tracksRemoved(guildId, tracks, position, oldStoredQueue, newStoredQueue) { console.log( `${this.client.guilds.cache.get(guildId)?.name || guildId}: ${tracks.length} Tracks got removed from the Queue at position #${position}`, ); } } client.lavalink = new LavalinkManager({ // ... other options queueOptions: { queueChangesWatcher: new myCustomWatcher(client), }, }); ``` -------------------------------- ### Initialize LavalinkManager with NodeLink Source: https://tomato6966.github.io/lavalink-client/index Initializes the LavalinkManager with the 'NodeLink' node type. This example shows basic initialization and a more comprehensive setup with various options. ```javascript client.lavalink = new LavalinkManager({ nodes: [ { host: "localhost", nodeType: "NodeLink", }, ], }); // or here if you need a bigger example. client.lavalink = new LavalinkManager({ nodes: [ { authorization: "youshallnotpass", // The password for your Lavalink server host: "localhost", port: 2333, id: "Main Node", // set to nodeLink nodeType: "NodeLink", }, ], // A function to send voice server updates to the Lavalink client sendToShard: (guildId, payload) => { const guild = client.guilds.cache.get(guildId); if (guild) guild.shard.send(payload); }, autoSkip: true, client: { id: process.env.CLIENT_ID, // Your bot's user ID username: "MyBot", }, }); ``` -------------------------------- ### Install Lavalink-Client Development Branch via BUN Source: https://tomato6966.github.io/lavalink-client/index Installs the development branch of the lavalink-client from GitHub using BUN. This provides access to the most recent code changes. ```bash bun add tomato6966/lavalink-client ``` -------------------------------- ### Player Method: changeNode Example Source: https://tomato6966.github.io/lavalink-client/api/player/classes/player An example demonstrating how to use the changeNode method to move a player to a new audio node. ```typescript const changeNode = await player.changeNode(newNode, true); ``` -------------------------------- ### Filter Tracks Example (Recommended) Source: https://tomato6966.github.io/lavalink-client/api/queue/classes/queue An example demonstrating the recommended way to filter tracks using the `utils.filterTracks` method, specifying criteria like the track author. ```javascript // Use the new method instead: const artistTracks = player.queue.utils.filterTracks({ author: "Artist Name" }); ``` -------------------------------- ### Enable and Listen to Lavalink Client Debug Events Source: https://tomato6966.github.io/lavalink-client/home/example Configures the Lavalink manager to enable debug events and sets up a listener to log these events. It demonstrates how to selectively skip certain debug messages based on event key and data, providing a cleaner debugging experience. ```javascript import { DebugEvents } from "lavalink-client"; // YOU NEED TO HAVE THE debug EVENT ENABLED /* client.lavalink = new LavalinkManager({ .... advancedOptions: { enableDebugEvents: true, // enable the DEBUG EVENT LISTENER debugOptions: { noAudio: true, // if set to true, you will get additional logs related to not hearing audio while playing on the first setup playerDestroy: { dontThrowError: false, debugLog: false, // if set to true, you will see additional debug logs related to destroying players }, logCustomSearches: false, // if set to true, you will see logs related to custom search plugins. } } }); */ client.lavalink.on("debug", (eventKey, eventData) => { // skip specific log if (eventKey === DebugEvents.NoAudioDebug && eventData.message === "Manager is not initated yet") return; // skip specific event log of a log-level-state "log" if (eventKey === DebugEvents.PlayerUpdateSuccess && eventData.state === "log") return; console.group("Lavalink-Client-Debug:"); console.log("-".repeat(20)); console.debug(`[${eventKey}]`); console.debug(eventData); console.log("-".repeat(20)); console.groupEnd(); }); ``` -------------------------------- ### Install Lavalink-Client Development Branch via NPM Source: https://tomato6966.github.io/lavalink-client/index Installs the development branch of the lavalink-client from GitHub using NPM. This is useful for testing the latest features or contributing to the project. ```bash npm install --save tomato6966/lavalink-client ``` -------------------------------- ### Install Lavalink-Client Development Branch via YARN Source: https://tomato6966.github.io/lavalink-client/index Installs the development branch of the lavalink-client from GitHub using YARN. This allows access to the latest unreleased features. ```bash yarn add tomato6966/lavalink-client ``` -------------------------------- ### Install Lavalink-Client via BUN Source: https://tomato6966.github.io/lavalink-client/index Installs the latest stable version of the lavalink-client package using BUN. BUN is a fast JavaScript runtime and package manager. ```bash bun add lavalink-client ``` -------------------------------- ### Install Lavalink-Client via NPM Source: https://tomato6966.github.io/lavalink-client/index Installs the latest stable version of the lavalink-client package using NPM. This is the recommended method for most users. ```bash npm install --save lavalink-client ``` -------------------------------- ### Example: Using rawListeners (JavaScript) Source: https://tomato6966.github.io/lavalink-client/api/lavalinkmanager/classes/lavalinkmanager This JavaScript example illustrates the usage of `rawListeners` to retrieve listeners associated with an event. It shows how to access and invoke both one-time and persistent listeners, demonstrating their behavior. ```javascript import { EventEmitter } from 'node:events'; const emitter = new EventEmitter(); emitter.once('log', () => console.log('log once')); // Returns a new Array with a function `onceWrapper` which has a property // `listener` which contains the original listener bound above const listeners = emitter.rawListeners('log'); const logFnWrapper = listeners[0]; // Logs "log once" to the console and does not unbind the `once` event logFnWrapper.listener(); // Logs "log once" to the console and removes the listener logFnWrapper(); emitter.on('log', () => console.log('log persistently')); // Will return a new Array with a single function bound by `.on()` above const newListeners = emitter.rawListeners('log'); // Logs "log persistently" twice newListeners[0](); emitter.emit('log'); ``` -------------------------------- ### Install Lavalink-Client Development Branch via pnpm Source: https://tomato6966.github.io/lavalink-client/index Installs the development branch of the lavalink-client from GitHub using pnpm. This is useful for developers who want to work with the latest code. ```bash pnpm add tomato6966/lavalink-client ``` -------------------------------- ### Install Lavalink-Client via YARN Source: https://tomato6966.github.io/lavalink-client/index Installs the latest stable version of the lavalink-client package using YARN. This is an alternative package manager to NPM. ```bash yarn add lavalink-client ``` -------------------------------- ### Handle Lavalink Node Connection and Errors Source: https://tomato6966.github.io/lavalink-client/home/example This code demonstrates how to listen for 'create' and 'error' events from the Lavalink NodeManager. It logs when a Lavalink node connects and logs any errors that occur, along with the associated payload for debugging. ```typescript client.lavalink.on("create", (node, payload) => { console.log(`The Lavalink Node #${node.id} connected`); }); // for all node based errors: client.lavalink.on("error", (node, error, payload) => { console.error(`The Lavalink Node #${node.id} errored: `, error); console.error(`Error-Payload: `, payload); }); ``` -------------------------------- ### Initialize Lavalink Manager with Discord.js Client Source: https://tomato6966.github.io/lavalink-client/home/example This snippet shows how to initialize the LavalinkManager and integrate it with a discord.js client. It sets up the necessary intents for voice states and binds the LavalinkManager instance to the client object. The manager is then initialized with the bot's user information. ```typescript import { LavalinkManager } from "lavalink-client"; import { Client, GatewayIntentBits } from "discord.js"; // example for a discord bot // you might want to extend the types of the client, to bind lavalink to it. const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates], }); // create instance client.lavalink = new LavalinkManager({ nodes: [ { authorization: "youshallnotpass", host: "localhost", port: 2333, id: "testnode", }, ], sendToShard: (guildId, payload) => client.guilds.cache.get(guildId)?.shard?.send(payload), autoSkip: true, client: { id: envConfig.clientId, username: "TESTBOT", }, }); client.on("raw", (d) => client.lavalink.sendRawData(d)); // send raw data to lavalink-client to handle stuff client.on("ready", () => { client.lavalink.init(client.user); // init lavalink }); ``` -------------------------------- ### Resume Player Sessions on Lavalink Connect/Resume Source: https://tomato6966.github.io/lavalink-client/home/example Handles the 'connect' and 'resumed' events from the Lavalink node manager. It resumes player sessions by fetching saved player data and recreating players with their previous state, including volume, channel IDs, and filters. It also handles cases where the bot might have disconnected, skipping resumption for those players. ```javascript client.lavalink.nodeManager.on("connect", (node) => node.updateSession(true, 360e3)); client.lavalink.nodeManager.on("resumed", (node, payload, fetchedPlayers) => { // create players: for(const fetchedPlayer of fetchedPlayers) { // fetchedPlayer is the live data from lavalink // saved Player data is the config you should save in a database / file or smt const savedPlayerData = await getSavedPlayerData(fetchedPlayer.guildId); const player = client.lavalink.createPlayer({ guildId: fetchedPlayer.guildId, }); // if lavalink says the bot got disconnected, we can skip the resuming, or force reconnect whatever you want!, here we choose to not do anything and thus delete the saved player data if(!data.state.connected) { console.log("skipping resuming player, because it already disconnected"); await deletedSavedPlayerData(data.guildId); continue; } // now you can create the player based on the live and saved data const player = client.lavalink.createPlayer({ guildId: data.guildId, node: node.id, // you need to update the volume of the player by the volume of lavalink which might got decremented by the volume decrementer volume: client.lavalink.options.playerOptions?.volumeDecrementer ? Math.round(data.volume / client.lavalink.options.playerOptions.volumeDecrementer) : data.volume, // all of the following options are needed to be provided by some sort of player saving voiceChannelId: dataOfSaving.voiceChannelId, textChannelId: dataOfSaving.textChannelId, // all of the following options can either be saved too, or you can use pre-defined defaults selfDeaf: dataOfSaving.options?.selfDeaf || true, selfMute: dataOfSaving.options?.selfMute || false, applyVolumeAsFilter: dataOfSaving.options.applyVolumeAsFilter, instaUpdateFiltersFix: dataOfSaving.options.instaUpdateFiltersFix, vcRegion: dataOfSaving.options.vcRegion, }); // player.voice = data.voice; // normally just player.voice is enough, but if you restart the entire bot, you need to create a new connection, thus call player.connect(); await player.connect(); player.filterManager.data = data.filters; // override the filters data await player.queue.utils.sync(true, false); // get the queue data including the current track (for the requester) // override the current track with the data from lavalink if(data.track) player.queue.current = client.lavalink.utils.buildTrack(data.track, player.queue.current?.requester || client.user); // override the position of the player player.lastPosition = data.position; player.lastPositionChange = Date.now(); // you can also override the ping of the player, or wait about 30s till it's done automatically player.ping.lavalink = data.state.ping; // important to have skipping work correctly later player.paused = data.paused; player.playing = !data.paused && !!data.track; // That's about it } }) client.lavalink.on("playerUpdate", (oldPlayer, newPlayer) => { // automatically sync player data on updates. if you don'T want to save everything you can instead also just save the data on playerCreate setSavedPlayerData(newPlayer.toJSON()); }); // delete the player again client.lavalink.on("playerDestroy", (player) => { deleteSavedPlayerData(player.guildId); }) ``` -------------------------------- ### get() Source: https://tomato6966.github.io/lavalink-client/api/utils/classes/minimap Returns a specified element from the Map object. ```APIDOC ## get() ### Description Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map. ### Method `get` ### Endpoint N/A (Method on Map object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript const value = map.get(key); ``` ### Response #### Success Response (200) `V` - The element associated with the specified key. Returns `undefined` if the key is not found. #### Response Example ```json { "example": "value associated with the key" } ``` ``` -------------------------------- ### Example Usage of addAbortListener() in JavaScript Source: https://tomato6966.github.io/lavalink-client/api/lavalinkmanager/classes/lavalinkmanager Provides an example of using the static addAbortListener method to handle abort signals safely. It demonstrates adding an event listener and ensuring the disposable resource is cleaned up. ```javascript import { addAbortListener } from 'node:events'; function example(signal) { let disposable; try { signal.addEventListener('abort', (e) => e.stopImmediatePropagation()); disposable = addAbortListener(signal, (e) => { // Do something when signal is aborted. }); } finally { disposable?.[Symbol.dispose](); } } ``` -------------------------------- ### Install Lavalink-Client via pnpm Source: https://tomato6966.github.io/lavalink-client/index Installs the latest stable version of the lavalink-client package using pnpm. pnpm is a performant package manager that saves disk space. ```bash pnpm add lavalink-client ``` -------------------------------- ### Handle Node Manager Connection and Errors Source: https://tomato6966.github.io/lavalink-client/home/example This snippet shows how to subscribe to 'create' and 'error' events specifically from the NodeManager within the Lavalink client. It logs when a node is created and logs any errors encountered by the NodeManager, including the error details and payload. ```typescript client.lavalink.nodeManager.on("create", (node, payload) => { console.log(`The Lavalink Node #${node.id} connected`); }); // for all node based errors: client.lavalink.nodeManager.on("error", (node, error, payload) => { console.error(`The Lavalink Node #${node.id} errored: `, error); console.error(`Error-Payload: `, payload); }); ``` -------------------------------- ### Complete Lavalink Client Configuration with Custom Queue Management Source: https://tomato6966.github.io/lavalink-client/index An extensive example showcasing almost all configuration options for LavalinkManager, including custom Redis queue storage and a queue changes watcher. It also demonstrates extending the Discord.js Client type. ```typescript import { LavalinkManager, QueueChangesWatcher, QueueStoreManager, StoredQueue } from "lavalink-client"; import { RedisClientType, createClient } from "redis"; import { Client, GatewayIntentBits, User } from "discord.js"; // It's recommended to extend the Client type declare module "discord.js" { interface Client { lavalink: LavalinkManager; redis: RedisClientType; } } const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates], }); client.lavalink = new LavalinkManager({ nodes: [ { authorization: "youshallnotpass", host: "localhost", port: 2333, id: "testnode", secure: false, // Set to true for wss:// retryAmount: 5, retryDelay: 10_000, // 10 seconds }, ], sendToShard: (guildId, payload) => client.guilds.cache.get(guildId)?.shard?.send(payload), autoSkip: true, // automatically play the next song of the queue, on: trackend, trackerror, trackexception client: { id: process.env.CLIENT_ID, username: "TESTBOT", }, playerOptions: { applyVolumeAsFilter: false, clientBasedPositionUpdateInterval: 50, defaultSearchPlatform: "ytmsearch", volumeDecrementer: 0.75, onDisconnect: { autoReconnect: true, destroyPlayer: false, }, onEmptyQueue: { destroyAfterMs: 30_000, // function get's called onqueueempty, and if there are songs added to the queue, it continues playing. if not then not (autoplay functionality) // autoPlayFunction: async (player) => { /* ... */ }, }, useUnresolvedData: true, }, queueOptions: { maxPreviousTracks: 10, queueStore: new MyCustomRedisStore(client.redis), queueChangesWatcher: new MyCustomQueueWatcher(client), }, // Whitelist/Blacklist links or words linksAllowed: true, linksBlacklist: ["somebadsite.com"], linksWhitelist: [], advancedOptions: { debugOptions: { noAudio: false, playerDestroy: { dontThrowError: false, debugLog: false }, }, }, }); client.on("raw", (d) => client.lavalink.sendRawData(d)); client.on("ready", () => client.lavalink.init({ ...client.user })); // Example Custom Redis Queue Store class MyCustomRedisStore implements QueueStoreManager { private redis: RedisClientType; constructor(redisClient: RedisClientType) { this.redis = redisClient; } private key(guildId: string) { return `lavalinkqueue_${guildId}`; } async get(guildId: string) { return await this.redis.get(this.key(guildId)); } async set(guildId: string, data: string) { return await this.redis.set(this.key(guildId), data); } async delete(guildId: string) { return await this.redis.del(this.key(guildId)); } async parse(data: string): Promise> { return JSON.parse(data); } stringify(data: Partial): string { return JSON.stringify(data); } } // Example Custom Queue Watcher class MyCustomQueueWatcher implements QueueChangesWatcher { private client: Client; constructor(client: Client) { this.client = client; } shuffled(guildId: string) { console.log(`Queue shuffled in guild: ${guildId}`); } } ``` -------------------------------- ### Get YouTube Configuration Details (TypeScript) Source: https://tomato6966.github.io/lavalink-client/api/nodelink/classes/nodelinknode Fetches YouTube configuration details from the NodeLink. Optionally validates the configuration. Returns a Promise that resolves to an object containing isConfigured, isValid, refreshToken, and visitorData. ```typescript getYoutubeConfig(validate?: boolean): Promise<{ isConfigured: boolean; isValid: boolean; refreshToken: string; visitorData: string; }>; ``` -------------------------------- ### Example Usage of sendRawData() in JavaScript Source: https://tomato6966.github.io/lavalink-client/api/lavalinkmanager/classes/lavalinkmanager Demonstrates how to use the sendRawData method within a 'raw' event listener on a client. This is crucial for the library's functionality, enabling audio transmission and channel event handling. ```javascript // on the bot "raw" event client.on("raw", (d) => { // required in order to send audio updates and register channel deletion etc. client.lavalink.sendRawData(d) }) ``` -------------------------------- ### Cancel Event Iteration with AbortSignal (Node.js) Source: https://tomato6966.github.io/lavalink-client/api/nodemanager/classes/nodemanager This example shows how to use an AbortSignal with the 'on' function to cancel the event iteration. An AbortController is used to signal the abortion, which stops the AsyncIterator from yielding further events. ```javascript import { on, EventEmitter } from 'node:events'; import process from 'node:process'; const ac = new AbortController(); (async () => { const ee = new EventEmitter(); // Emit later on process.nextTick(() => { ee.emit('foo', 'bar'); ee.emit('foo', 42); }); for await (const event of on(ee, 'foo', { signal: ac.signal })) { // The execution of this inner block is synchronous and it // processes one event at a time (even with await). Do not use // if concurrent execution is required. console.log(event); // prints ['bar'] [42] } // Unreachable here })(); process.nextTick(() => ac.abort()); ``` -------------------------------- ### Get Node ID (TypeScript Getter) Source: https://tomato6966.github.io/lavalink-client/api/nodelink/classes/nodelinknode A getter method that returns the unique identifier string of the Lavalink Node. Includes an example of how to retrieve and log the node ID. ```typescript get id(): string; // Example: const nodeId = player.node.id; console.log("node id is: ", nodeId) ``` -------------------------------- ### Get Node Connection Status String (TypeScript Getter) Source: https://tomato6966.github.io/lavalink-client/api/nodelink/classes/nodelinknode A getter method that returns a string representing the current connection status of the Lavalink Node. Includes an example demonstrating its usage and error handling. ```typescript get connectionStatus(): string; // Example: try { const statusOfConnection = player.node.connectionStatus; console.log("node's connection status is:", statusOfConnection) } catch (error) { console.error("no socket available?", error) } ``` -------------------------------- ### Use flowerytts Plugin with Extra Parameters (JavaScript) Source: https://tomato6966.github.io/lavalink-client/index This example demonstrates how to use the flowerytts plugin with the Lavalink client. It shows how to construct extra query parameters, such as voice selection, and pass them to the player.search function to enable plugin-specific features. The code assumes an interaction object with options for text and voice. ```javascript // Example for flowertts plugin const query = interaction.options.getString("text"); const voice = interaction.options.getString("voice"); // e.g., "MALE_1" const extraParams = new URLSearchParams(); if (voice) extraParams.append(`voice`, voice); // All params for flowertts can be found here: https://flowery.pw/docs const response = await player.search( { query: `${query}`, // This is used by plugins like ftts to adjust the request extraQueryUrlParams: extraParams, source: "ftts", // Specify the plugin source }, interaction.user, // The requester ); // Add the TTS track to the queue if (response.tracks.length > 0) { player.queue.add(response.tracks[0]); if (!player.playing) player.play(); } ``` -------------------------------- ### Get Tracks from Queue (TypeScript) Source: https://tomato6966.github.io/lavalink-client/api/queue/classes/queue Retrieves a range of tracks from the queue. This method returns a new array slice and does not modify the original queue. It takes a start index (inclusive) and an optional end index (exclusive). ```typescript getTracks(start: number, end?: number): ( | UnresolvedTrack | Track)[]; ``` -------------------------------- ### Perform Raw Request to Lavalink Node Source: https://tomato6966.github.io/lavalink-client/api/nodelink/classes/nodelinknode A utility function for making raw HTTP requests to the Lavalink node. It allows specifying an endpoint and modifying the request options. An example shows how to perform a GET request to the `/loadtracks` endpoint. ```javascript player.node.rawRequest(`/loadtracks?identifier=Never gonna give you up`, (options) => options.method = "GET"); ``` ```typescript rawRequest(endpoint: string, modify?: ModifyRequest): Promise<{ options: RequestInit & object; response: Response; }>; ``` -------------------------------- ### DefaultQueueStore Constructor Source: https://tomato6966.github.io/lavalink-client/api/queue/classes/defaultqueuestore Initializes a new instance of the DefaultQueueStore class. ```APIDOC ## new DefaultQueueStore() ### Description Initializes a new instance of the DefaultQueueStore class. ### Method CONSTRUCTOR ### Endpoint N/A ### Parameters None ### Request Example ```json // No request body for constructor ``` ### Response #### Success Response (200) - **instance** (DefaultQueueStore) - A new instance of DefaultQueueStore. #### Response Example ```json { "message": "DefaultQueueStore instance created successfully" } ``` ``` -------------------------------- ### Configure Lavalink Server and Plugins (YAML) Source: https://tomato6966.github.io/lavalink-client/home/setup-lavalink This YAML configuration sets up the Lavalink server port, password, and buffer durations. It also enables multiple plugins for extended functionality, including YouTube, LavaSrc, LavaSearch, and lyric providers. ```yaml server: port: 2333 address: 0.0.0.0 lavalink: server: sources: youtube: false # Using Youtube nativly on lavalink is deprecated, disable it and use https://github.com/lavalink-devs/youtube-source instead. password: "youshallnotpass" bufferDurationMs: 225 frameBufferDurationMs: 5000 youtubePlaylistLoadLimit: 3 opusEncodingQuality: 5 resamplingQuality: MEDIUM trackStuckThresholdMs: 5000 playerUpdateInterval: 3 useSeekGhosting: true youtubeSearchEnabled: true soundcloudSearchEnabled: true gc-warnings: true plugins: - dependency: "dev.lavalink.youtube:youtube-plugin:1.18.0" # https://github.com/lavalink-devs/youtube-source - dependency: "com.github.topi314.lavasrc:lavasrc-plugin:4.8.1" # https://github.com/topi314/LavaSrc - dependency: "com.github.topi314.lavasearch:lavasearch-plugin:1.0.0" # https://github.com/topi314/LavaSearch - dependency: "com.dunctebot:skybot-lavalink-plugin:1.7.0" # https://github.com/DuncteBot/skybot-lavalink-plugin - dependency: "com.github.devoxin:lavadspx-plugin:0.0.5" # https://github.com/devoxin/LavaDSPX-Plugin repository: "https://jitpack.io" - dependency: "com.github.topi314.lavalyrics:lavalyrics-plugin:1.1.0" # https://github.com/topi314/LavaLyrics - dependency: "me.duncte123:java-lyrics-plugin:1.6.6" # https://github.com/DuncteBot/java-timed-lyrics plugins: lyrics: countryCode: de geniusApiKey: "" lavalyrics: sources: - genius - spotify - youtube - deezer - yandexMusic youtube: enabled: true # YouTube's cipher changes are becoming more frequent and complex, making it harder to keep up. # To simplify signature deciphering, you can use a remote cipher server like yt-cipher, a lightweight Deno server with a REST API. More details are available at https://github.com/kikkia/yt-cipher remoteCipher: userAgent: "your_service_name" url: "http://localhost:8001" # The base URL of your remote cipher server. password: "your_secret_password" # The password to authenticate with your remote cipher server. oauth: enabled: false # refreshToken: "Insert your refresh token here" # For more details, please refer to https://github.com/lavalink-devs/youtube-source?tab=readme-ov-file#using-oauth-tokens allowSearch: true allowDirectVideoIds: true allowDirectPlaylistIds: true # For more details about client setup, refer to https://github.com/lavalink-devs/youtube-source?tab=readme-ov-file#available-clients clients: - "ANDROID_MUSIC" - "MUSIC" - "WEB" - "WEBEMBEDDED" - "TVHTML5_SIMPLY" ANDROID_MUSIC: videoLoading: true searching: true playback: true MUSIC: searching: true playback: false WEB: videoLoading: true searching: true playback: true WEBEMBEDDED: playback: true TVHTML5_SIMPLY: playback: true lavasrc: providers: - 'ytsearch:"%ISRC%"' - "dzisrc:%ISRC%" - "ytsearch:%QUERY%" - "dzsearch:%QUERY%" - "jssearch:%QUERY%" - "pdsearch:%QUERY%" - "scsearch:%QUERY%" - "tdsearch:%QUERY%" sources: spotify: true # Enable Spotify source applemusic: true # Enable Apple Music source deezer: true # Enable Deezer source jiosaavn: true # Enabled JioSaavn source pandora: true # Enable Pandora source yandexmusic: true # Enable Yandex Music source flowerytts: true # Enable Flowery TTS source youtube: true # Enable YouTube search source (https://github.com/topi314/LavaSearch) tidal: true # Enable Tidal source vkmusic: true # Enable Vk Music source qobuz: true # Enabled qobuz source ytdlp: true # Enable yt-dlp source lyrics-sources: spotify: true # Enable Spotify lyrics source deezer: true # Enable Deezer lyrics source youtube: true # Enable YouTube lyrics source yandexmusic: true # Enable Yandex Music lyrics source vkmusic: true # Enable Vk Music lyrics source lrcLib: true # Enable LRC Library lyrics source (https://lrclib.net) spotify: # clientId & clientSecret are required for using spsearch ``` -------------------------------- ### Listen to Lavalink Manager Events (JavaScript) Source: https://tomato6966.github.io/lavalink-client/index Examples of listening to Lavalink manager events like 'trackStart' and 'queueEnd'. These events allow for interactive responses to music playback status changes. The 'trackStart' event sends a message when a new track begins, and 'queueEnd' sends a message and destroys the player when the queue is empty. ```javascript client.lavalink.on("trackStart", (player, track) => { const channel = client.channels.cache.get(player.textChannelId); if (channel) channel.send(`Now playing: ${track.info.title}`); }); client.lavalink.on("queueEnd", (player) => { const channel = client.channels.cache.get(player.textChannelId); if (channel) channel.send("The queue has finished. Add more songs!"); player.destroy(); }); ``` -------------------------------- ### SponsorBlockChapterStarted Event Details Source: https://tomato6966.github.io/lavalink-client/api/types/utils/interfaces/sponsorblockchapterstarted Provides a detailed breakdown of the SponsorBlockChapterStarted event, including its properties and their types. ```APIDOC ## SponsorBlockChapterStarted Event ### Description This event is triggered when a new SponsorBlock chapter starts. It extends the base `PlayerEvent` and provides specific details about the chapter. ### Method Event (WebSocket) ### Endpoint N/A (Event-driven) ### Properties #### Event Properties - **op** (string) - The operation type, always "event". - **type** (string) - The type of the event, "ChapterStarted". - **guildId** (string) - The ID of the guild where the event occurred. #### Chapter Object (`chapter`) - **chapter** (object) - An object containing details about the chapter that started. - **name** (string) - The Name of the Chapter. - **start** (number) - The start timestamp of the chapter. - **end** (number) - The end timestamp of the chapter. - **duration** (number) - The duration of the chapter. ### Response Example ```json { "op": "event", "type": "ChapterStarted", "guildId": "1234567890", "chapter": { "name": "Intro", "start": 10.5, "end": 30.2, "duration": 19.7 } } ``` ``` -------------------------------- ### Lavalink Manager - init Source: https://tomato6966.github.io/lavalink-client/api/lavalinkmanager/classes/lavalinkmanager Initializes the Lavalink manager, creating and connecting all nodes. ```APIDOC ## POST /init ### Description Initiates the Manager, creates all nodes and connects all of them. ### Method POST ### Endpoint `/init` ### Parameters #### Request Body - **clientData** (BotClientOptions) - Required - An object containing client information. - **id** (string) - Required - The client's user ID. - **username** (string) - Required - The client's username. ### Request Example ```json { "clientData": { "id": "YOUR_CLIENT_ID", "username": "YourBotUsername" } } ``` ### Response #### Success Response (200) - **manager** (LavalinkManager) - The initialized Lavalink manager instance. #### Response Example ```json { "manager": { "//": "Represents the initialized LavalinkManager instance" } } ``` ``` -------------------------------- ### forEach() Source: https://tomato6966.github.io/lavalink-client/api/utils/classes/minimap Executes a provided function once for each key/value pair in the Map. ```APIDOC ## forEach() ### Description Executes a provided function once for each key/value pair in the Map, in insertion order. ### Method `forEach` ### Endpoint N/A (Method on Map object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript map.forEach((value, key) => { console.log(`Key: ${key}, Value: ${value}`); }); ``` ### Response #### Success Response (200) `void` #### Response Example None (This method does not return a value). ``` -------------------------------- ### Initialize Lavalink Manager Source: https://tomato6966.github.io/lavalink-client/api/lavalinkmanager/classes/lavalinkmanager Initiates the Lavalink manager, establishing connections to all configured nodes. This method should be called during the bot's ready event. ```typescript // on the bot ready event client.on("ready", () => { client.lavalink.init({ id: client.user.id, username: client.user.username }); }); ``` -------------------------------- ### MixStartedEvent Structure Source: https://tomato6966.github.io/lavalink-client/api/types/nodelink/interfaces/mixstartedevent Details the properties of the MixStartedEvent, which is emitted when a mix starts. ```APIDOC ## MixStartedEvent ### Description Represents an event triggered when a mix track begins playing in Lavalink. ### Properties - **guildId** (`string`) - The ID of the guild where the mix started. - **mixId** (`string`) - A unique identifier for the mix layer. - **op** (`"event"`) - Operation code, always 'event' for this type. - **track** (`LavalinkTrack`) - The full track information for the mix layer that started. - **type** (`"MixStartedEvent"`) - The type of the event, specifically 'MixStartedEvent'. - **volume** (`number`) - The volume level of the mix layer, ranging from 0.0 to 1.0. ``` -------------------------------- ### Build Plugin Info - ManagerUtils Source: https://tomato6966.github.io/lavalink-client/api/utils/classes/managerutils Builds a pluginInfo object from provided data and optional client data. This is used for consistent handling of plugin information associated with tracks. ```typescript buildPluginInfo(data: any, clientData?: any): any; ``` -------------------------------- ### Indexable Signature for BotClientOptions Source: https://tomato6966.github.io/lavalink-client/api/types/manager/interfaces/botclientoptions This section describes the indexable signature for BotClientOptions, allowing users to pass entire objects or classes as properties. It indicates that any string, number, or symbol can be used as a key for unknown values. ```typescript [x: string | number | symbol]: unknown ``` -------------------------------- ### SponsorBlock Events Source: https://tomato6966.github.io/lavalink-client/api/types/manager/interfaces/lavalinkmanagerevents Events related to the SponsorBlock plugin, such as chapters being loaded or starting. ```APIDOC ## Events: SponsorBlock ### ChaptersLoaded #### Description Emitted when Chapters are loaded via the Sponsorblock Plugin. #### Type (`player`: `CustomPlayerT`, `track`: `UnresolvedTrack` | `Track`, `payload`: `SponsorBlockChaptersLoaded`) => `void` ### ChapterStarted #### Description Emitted when a specific Chapter starts playing via the Sponsorblock Plugin. #### Type (`player`: `CustomPlayerT`, `track`: `UnresolvedTrack` | `Track`, `payload`: `SponsorBlockChapterStarted`) => `void` ``` -------------------------------- ### NodeManager Constructor Source: https://tomato6966.github.io/lavalink-client/api/nodemanager/classes/nodemanager Initializes a new instance of the NodeManager class. ```APIDOC ## Constructor NodeManager ### Description Initializes a new instance of the NodeManager class. ### Method ``` new NodeManager(LavalinkManager: LavalinkManager): NodeManager ``` ### Parameters #### Path Parameters - **LavalinkManager** (LavalinkManager) - Required - The LavalinkManager that created this NodeManager ### Returns #### Success Response (200) - **NodeManager** (NodeManager) - The newly created NodeManager instance. ### Request Example ```json { "LavalinkManager": "" } ``` ### Response Example ```json { "instance": "" } ``` ``` -------------------------------- ### PluginInfo Structure Source: https://tomato6966.github.io/lavalink-client/api/types/track/interfaces/plugininfo Details the properties available within the PluginInfo structure. ```APIDOC ## PluginInfo Structure ### Description Represents information about a plugin associated with a track. ### Properties #### albumArtUrl - **Type**: `string` - **Optional**: Yes - **Description**: The URL of the album art. #### albumName - **Type**: `string` - **Optional**: Yes - **Description**: The name of the album. #### albumUrl - **Type**: `string` - **Optional**: Yes - **Description**: The URL of the album. #### artistArtworkUrl - **Type**: `string` - **Optional**: Yes - **Description**: The URL of the artist's artwork. #### artistUrl - **Type**: `string` - **Optional**: Yes - **Description**: The URL of the artist. #### artworkUrl - **Type**: `string` - **Optional**: Yes - **Description**: The artwork URL provided by a plugin. #### author - **Type**: `string` - **Optional**: Yes - **Description**: Author information provided by a plugin. #### clientData - **Type**: `object` - **Optional**: Yes - **Description**: Custom client data associated with the track. - **clientData.previousTrack** (boolean) - Optional - Indicates if this is a previous track. #### identifier - **Type**: `string` - **Optional**: Yes - **Description**: The identifier provided by a plugin. #### isPreview - **Type**: `boolean` - **Optional**: Yes - **Description**: Whether the track is a preview. #### previewUrl - **Type**: `string` - **Optional**: Yes - **Description**: The URL of the track preview. #### totalTracks - **Type**: `number` - **Optional**: Yes - **Description**: The total number of tracks in the playlist. #### type - **Type**: `string` - **Optional**: Yes - **Description**: The type provided by a plugin. #### uri - **Type**: `string` - **Optional**: Yes - **Description**: The URI provided by a plugin. #### url - **Type**: `string` - **Optional**: Yes - **Description**: The URL provided by a plugin. ``` -------------------------------- ### EventEmitter - getMaxListeners Source: https://tomato6966.github.io/lavalink-client/api/lavalinkmanager/classes/lavalinkmanager Gets the current maximum number of listeners for the EventEmitter. ```APIDOC ## GET /getMaxListeners ### Description Returns the current max listener value for the `EventEmitter` which is either set by `emitter.setMaxListeners(n)` or defaults to EventEmitter.defaultMaxListeners. ### Method GET ### Endpoint `/getMaxListeners` ### Response #### Success Response (200) - **maxListeners** (number) - The current maximum number of listeners. #### Response Example ```json { "maxListeners": 10 } ``` ``` -------------------------------- ### Get Current Track Lyrics (TypeScript) Source: https://tomato6966.github.io/lavalink-client/api/nodelink/classes/nodelinknode Fetches the lyrics for the currently playing track in a guild. This function requires the guild ID and an optional boolean to skip the track source, returning a promise that resolves to LyricsResult. It offers a convenient way to get lyrics for the active song. ```typescript // Using the node directly: // const lyrics = await player.node.lyrics.getCurrent(guildId); // Using the player instance: // const lyrics = await player.getCurrentLyrics(); ``` -------------------------------- ### NodeManager - getMaxListeners Source: https://tomato6966.github.io/lavalink-client/api/nodemanager/classes/nodemanager Gets the current maximum number of listeners allowed for any single event on the NodeManager. ```APIDOC ## GET /listeners/max ### Description Retrieves the current maximum listener count for the NodeManager. This value can be set using `setMaxListeners`. ### Method GET ### Endpoint `/listeners/max` ### Response #### Success Response (200) - **maxListeners** (number) - The maximum number of listeners allowed per event. #### Response Example ```json { "maxListeners": 10 } ``` ``` -------------------------------- ### Player Constructor Source: https://tomato6966.github.io/lavalink-client/api/player/classes/player Initializes a new Player instance. It requires PlayerOptions and a LavalinkManager instance. An optional boolean can prevent the emission of the playerCreate event. ```typescript new Player( options: PlayerOptions, LavalinkManager: LavalinkManager, dontEmitPlayerCreateEvent?: boolean): Player; ``` -------------------------------- ### Get Chapters API Source: https://tomato6966.github.io/lavalink-client/api/nodelink/classes/nodelinknode Retrieves chapters for YouTube videos associated with a player. ```APIDOC ## POST /sessions/{sessionId}/players/{guildId}/chapters ### Description Retrieve Chapters of Youtube Videos. ### Method POST ### Endpoint `/sessions/{sessionId}/players/{guildId}/chapters` ### Parameters #### Path Parameters - **sessionId** (string) - Required - The session ID of the player. - **guildId** (string) - Required - The ID of the guild the player is in. #### Query Parameters - **track** (object) - Optional - The track object (`UnresolvedTrack` or `Track`) to get chapters for. If not provided, it will use the current track. ### Request Example ```json { "track": { "identifier": "dQw4w9WgXcQ", "isStream": false, "isSeekable": true, "author": "Rick Astley", "channelId": "UC-lHJZR3Gqxm24_Vd_AJ5Yw", "channelName": "Rick Astley", "length": 212000, "position": 0, "title": "Rick Astley - Never Gonna Give You Up (Official Music Video)", "uri": "https://www.youtube.com/watch?v=dQw4w9WgXcQ", "artworkUrl": "https://i.ytimg.com/vi/dQw4w9WgXcQ/default.jpg", "requester": "user-id" } } ``` ### Response #### Success Response (200) - **NodeLinkChapter[]** (array) - Array of NodeLinkChapter objects (if empty, no chapters are available). #### Response Example ```json [ { "startTime": 0, "endTime": 60000, "title": "Introduction" }, { "startTime": 60000, "endTime": 120000, "title": "Verse 1" } ] ``` ```