LavalinkManager
The main Base-Manager of this Package
Type: class extends node:EventEmitter
Constructor
new LavalinkManager(options:ManagerOptions)
Import
import { LavalinkManager } from "lavalink-client";
Overview
Check out Example Creations down below
Properties
.initated
If the Manager was initated
Type: Boolean
.useable
If the Manager is useable (If at least 1 Node is connected)
Type: Boolean
.options
The options from the Manager
Type: ManagerOptions
.players
All the Players of the Manager
Type: MiniMap<guildId:string, Player>
.nodeManager
The Node Manager of the Manager
Type: NodeManager
.utils
The Manager's Utils
Type: ManagerUtils
Methods
Initializes the Manager and connects all Nodes
Returns: Promise<LavalinkManager>
botClient.on("ready", async () => { // only init it when the Bot is ready...
await botClient.lavalink.init({
id: botClient.user.id,
username: botclient.user.username
});
});
Create or get a Player
Returns: Player
const newPlayer = await client.lavalink.createPlayer({
guildId: interaction.guildId,
voiceChannelId: interaction.member.voice?.channelId,
textChannelId: interaction.channelId, // (optional)
selfDeaf: true, // (optional)
selfMute: false, // (optional)
volume: client.defaultVolume, // (optional) default volume
instaUpdateFiltersFix: true, // (optional)
applyVolumeAsFilter: false, // (optional)
// node: "YOUR_NODE_ID", // (optional)
// vcRegion: interaction.member.voice?.channel?.rtcRegion // (optional)
});
Create a Player
const player = client.lavalink.getPlayer(interaction.guildId);
Removes a Player from the saved MiniMap, needs to be destroyed first
Returns: Boolean
client.lavalink.deletePlayer(oldPlayer?.guildId || interaction.guildId);
.sendRawData(data : VoicePacket | VoiceServer | VoiceState | any) IMPORTANT!
Sends Raw Discord's Clients Event Data to the Manager
Returns: void
botClient.on("raw", (data) => client.lavalink.sendRawData(data));
Event-Listeners
All Events you can listen to on the LavalinkManager Class
trackStart
Emitted whenever a Track plays
client.lavalink.on("trackStart", (player, track, payload) => { });
trackEnd
Emitted whenever a Track finished playing.
client.lavalink.on("trackEnd", (player, track, payload) => { });
trackStuck
Emitted whenever a Track got stuck while playing
client.lavalink.on("trackStuck", (player, track, payload) => { });
trackError
Emitted whenever a Track errored
client.lavalink.on("trackError", (player, track, payload) => { });
queueEnd
Emitted when the track Ended, but there are no more tracks in the queue
(trackEnd, does NOT get exexcuted)
client.lavalink.on("queueEnd", (player, track, payload) => { });
playerCreate
Emitted whenver a Player gets created
client.lavalink.on("playerCreate", (player) => { });
playerMove
Emitted whenever a Player gets moved between Voice Channels
client.lavalink.on("playerMove", (player, oldVCId, newVCId) => { });
playerDisconnect
Emitted whenever a player is disconnected from a channel
client.lavalink.on("playerDisconnect", (player, voiceChannelId) => { });
playerSocketClose
Emitted when a Node-Socket got closed for a specific Player
client.lavalink.on("playerSocketClose", (player, track, payload) => { });
playerDestroy
Emitted whenever a Player got destroyed
client.lavalink.on("playerDestroy", (player, destroyReason) => { });
playerUpdate
Emitted whenever a Player gets an update from Lavalink's playerUpdate Event
client.lavalink.on("playerUpdate", (oldPlayerJson, newPlayer) => { });
Example-Creations
Advanced Example Creation
Last updated