Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
lavalink-client
Advanced tools
Readme
Easy, flexible and feature-rich lavalink@v4 Client. Both for Beginners and Proficients.
Latest stable Version: v2.1.3
npm install --save lavalink-client
Dev Version: (Current)
npm install tomato6966/lavalink-client
yarn add lavalink-client
Dev Version: (Current)
yarn add tomato6966/lavalink-client
Check out the Documentation | or the TSDocumentation for Examples, and detailled Docs, and to figure out how to get started. note: it's not fully done yet (see the docs)
💯 Lavalink v4 Supported only (with Lavalink Plugins)
✅ Player-Destroy Reasons like:
✨ Choose able queue stores (maps, collections, redis, databases, ...)
😍 Included Filter & Equalizer Management
👍 Multiple Player Options for easier use
🛡️ Lavalink Validations
🛡️ Client Validations
🧑💻 Memory friendly and easy style
😘 Automated Handlings
😁 Much much more!
Player related logs
playerCreate
➡️ (player) => {}
playerDestroy
➡️ (player, reason) => {}
playerDisconnect
➡️ (player, voiceChannelId) => {}
playerMove
➡️ (player, oldChannelId, newChannelId) => {}
playerSocketClosed
➡️ (player, payload) => {}
Track / Manager related logs
trackStart
➡️ (player, track, payload) => {}
trackStuck
➡️ (player, track, payload) => {}
trackError
➡️ (player, track, payload) => {}
trackEnd
➡️ (player, track, payload) => {}
queueEnd
➡️ (player, track, payload) => {}
playerUpdate
➡️ (player) => {}
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)
});
raw
➡️ (node, payload) => {}
disconnect
➡️ (node, reason) => {}
connect
➡️ (node) => {}
reconnecting
➡️ (node) => {}
create
➡️ (node) => {}
destroy
➡️ (node) => {}
error
➡️ (node, error, payload) => {}
resumed
➡️ (node, payload, players) => {}
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)
});
When creating the manager, add the option:
queueOptions.queueChangesWatcher: new myCustomWatcher(botClient)
E.g:
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)
}
})
player.stopPlaying()
: When executed it clears the Queue and stops playing, without destroying the PlayerPlayer.skip()
throwError
Property to: player.skip(skipTo?:number = 0, throwError?:boolean = true)
.
player.getSponsorBlock()
/ node.getSponsorBlock()
player.setSponsorBlock(segments:SponsorBlockSegment[])
/ node.setSponsorBlock(segments:SponsorBlockSegment[])
player.deleteSponsorBlock()
/ node.deleteSponsorBlock()
"SegmentsLoaded"
, "SegmentSkipped"
, "ChapterStarted"
, "ChaptersLoaded"
ManagerOptions#emitNewSongsOnly
. If set to true, it won't emit "trackStart" Event, when track.loop is active, or the new current track == the previous (current) track.ManagerOptions#linksBlacklist
which allows user to specify an array of regExp / strings to match query strings (for links / words) and if a match happens it doesn't allow the request (blacklist)ManagerOptions#linksWhitelist
which allows user to specify an array of regExp / strings to match query strings (for links only) and if a match does NOT HAPPEN it doesn't allow the request (whitelist)ManagerOptions#linksAllowed
if set to false, it does not allow requests which are linksManaagerOptions#debugOptions
to ManaagerOptions#advancedOptions.debugOptions
player.stopPlaying()
stopPlaying(clearQueue:boolean = true, executeAutoplay:boolean = false)
.
parseLavalinkConnUrl(connectionUrl:string)
Util Function.
lavalink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>
{ id: string, authorization: string, host: string, port: number }
parseLavalinkConnUrl("lavalink://LavalinkNode_1:strong%23password1@localhost:2345")
will give you:
{ id: "LavalinkNode_1", authorization: "strong#password1", host: "localhost", port: 2345 }
# How to load tracks / stop playing has changed for the node.updatePlayer rest endpoint the Client handles it automatically
- await player.node.updatePlayer({ encodedTrack?: Base64|null, track?: Track|UnresolvedTrack, identifer?: string });
+ await player.node.updatePlayer({ track: { encoded?: Base64|null, identifier?: string }, clientTrack?: Track|UnresolvedTrack });
# To satisfy the changes from lavalink updatePlayer endpoint, player play also got adjusted for that (Most users won't need this feature!)
- await player.play({ encodedTrack?: Base64|null, track?: Track|UnresolvedTrack, identifer?: string });
+ await player.play({ track: { encoded?: Base64|null, identifier?: string }, clientTrack?: Track|UnresolvedTrack });
# However it' still recommended to do it like that:
# first add tracks to the queue
+ await player.queue.add(Track: Track|UnresolvedTrack|(Track|UnresolvedTrack)[]);
# then play the next track from the queue
+ await player.play();
# Node Resuming got supported
# First enable it by doing:
+ await player.node.updateResuming(true, 360_000);
# then when reconnecting to the node add to the node.createeOptions the sessionId: "" of the previous session
# and after connecting the nodeManager.on("resumed", (node, payload, players) => {}) will be executed, where you can sync the players!
# Node Options got adjusted # It's a property not a method should be treated readonly
+ node.resuming: { enabled: boolean, timeout: number | null };
# Player function got added to stop playing without disconnecting
+ player.stopPlaying(clearQueue:boolean = true, executeAutoplay:boolean = false);
# Node functions for sponsorBlock Plugin (https://github.com/topi314/Sponsorblock-Plugin) got added
+ deleteSponsorBlock(player:Player)
+ setSponsorBlock(player:Player, segments: ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "filler"])
# only works if you ever set the sponsor blocks once before
+ getSponsorBlock(player:Player)
# Corresponding nodeManager events got added:
+ nodeManager.on("ChapterStarted");
+ nodeManager.on("ChaptersLoaded");
+ nodeManager.on("SegmentsLoaded");
+ nodeManager.on("SegmentSkipped");
# Filters sending got supported for filters.pluginFilters key from lavalink api: https://lavalink.dev/api/rest.html#plugin-filters
# Native implementation for lavaSearch plugin officially updated https://github.com/topi314/LavaSearch
# Native implementation for lavaSrc plugin officially updated https://github.com/topi314/LavaSrc including floweryTTS
# couple other changes, which aren't noticeable by you.
# Lavalink track.userData got added (basically same feature as my custom pluginInfo.clientData system)
# You only get the track.userData data through playerUpdate object
In one of the next updates, there will be more queueWatcher options and more custom nodeevents to trace
Most features of this update got tested, but if you encounter any bugs feel free to open an issue!
player.filterManager.filters.lavalinkLavaDspxPlugin
player.filterManager.filters.lavalinkLavaDspxPlugin.echo
player.filterManager.filters.lavalinkLavaDspxPlugin.normalization
player.filterManager.filters.lavalinkLavaDspxPlugin.highPass
player.filterManager.filters.lavalinkLavaDspxPlugin.lowPass
player.filterManager.filters.lavalinkFilterPlugin
(this plugins seems to not work on v4 at the moment)
player.filterManager.filters.lavalinkLavaDspxPlugin.echo
player.filterManager.filters.lavalinkLavaDspxPlugin.reverb
player.filterManager.lavalinkLavaDspxPlugin
player.filterManager.lavalinkLavaDspxPlugin.toggleEcho(decay:number, echoLength:number)
player.filterManager.lavalinkLavaDspxPlugin.toggleNormalization(maxAmplitude:number, adaptive:boolean)
player.filterManager.lavalinkLavaDspxPlugin.toggleHighPass(boostFactor:number, cutoffFrequency:number)
player.filterManager.lavalinkLavaDspxPlugin.toggleLowPass(boostFactor:number, cutoffFrequency:number)
player.filterManager.lavalinkFilterPlugin
player.filterManager.lavalinkFilterPlugin.toggleEcho(delay:number, decay:number)
player.filterManager.lavalinkFilterPlugin.toggleReverb(delays:number[], gains:number[])
FAQs
Easy, flexible and feature-rich lavalink@v4 Client. Both for Beginners and Proficients.
The npm package lavalink-client receives a total of 150 weekly downloads. As such, lavalink-client popularity was classified as not popular.
We found that lavalink-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.