aqualink
v1.5.2-beta
Published
An Lavalink wrapper, focused in speed, performance, and features, Based in Riffy!
Downloads
1,028
Maintainers
Readme
AquaLink
An Stable, performant, Recourse friendly and fast lavalink wrapper
This code is based in riffy, but its an 100% Rewrite made from scratch...
Why use AquaLink
- In dev
- Very Low memory comsuption
- Built in Queue manager
- Lots of features to use
- Lowest CPU Usage
- Very fast (mine take less than 1 second to load an song!)
- 1 Player created = ~1 - 0,5 mb per player
- Auto clean Up memory when song finishes / bot leave the vc
- Plugin system
- Lavalink v4 support (din't test v3)
- Youtube and Spotify support
- Minimal Requests to the lavalink server (helps the lavalink recourses!)
- Easy player, node, aqua managing
- Fast responses from rest and node
- Playlist support (My mix playlists, youtube playlists)
Docs (Wiki)
https://github.com/ToddyTheNoobDud/AquaLink/wiki
Example bot: https://github.com/ToddyTheNoobDud/Thorium-Music
Yay, Version 1.5.0 || 1.5.1 || 1.5.2 is released, wow
- 1.5.2-Beta
- Actually fixed destroy now (i had forgot the queue handling and deleting)
- Update undici to 7.2.0
- Implement undici gargabe collector to REST and FetchImage (this can reduce the overall memory usage, experimental) (reference is This)
- Made some fixes on Player too
- Why beta (all features are not complete yet, its on testing)
1.5.1 :
- Fully fixed destroy and the queue handling for delete, also now it deletes from lavalink...
1.5.0:
- Optimized memory usage in
FetchImage
by removing unnecessary code and saving, addressing some memory leaks. - Updated
AQUA
with additional cleanup options, faster response arrays, RemadeConstructResponse
andresolve
, and improved theUpdateVoice
handler. - Updated
CONNECTION
to fix bugs, improve the cleanup system, and Improve speed. - Improved cleanup in the
NODE
manager and fixed issues for VPS. - Rewrited the
TRACK
handler for better speed by removing redundant checks and code. - REMADE the
PLAYER
system to fix bugs, resolve message sending issues, FixesEventEmitter
memory leaks (also FixesAQUA
), remove unnecessary JSDoc comments, rewrite some methods, and enhance cleanup.
How to install
npm install aqualink
pnpm install aqualink
Basic usage
// If you're using Module, use this:
// import { createRequire } from 'module';
// const require = createRequire(import.meta.url);
//const { Aqua } = require('aqualink');
const { Aqua } = require("aqualink");
const { Client, Collection, GatewayDispatchEvents } = require("discord.js");
const client = new Client({
intents: [
"Guilds",
"GuildMembers",
"GuildMessages",
"MessageContent",
"GuildVoiceStates"
]
});
const nodes = [
{
host: "127.0.0.1",
password: "yourpass",
port: 233,
secure: false,
name: "localhost"
}
];
const aqua = new Aqua(client, nodes, {
send: (payload) => {
const guild = client.guilds.cache.get(payload.d.guild_id);
if (guild) guild.shard.send(payload);
},
defaultSearchPlatform: "ytsearch",
restVersion: "v4"
});
client.aqua = aqua;
client.once("ready", () => {
client.aqua.init(client.user.id);
console.log("Ready!");
});
client.on("raw", (d) => {
if (![GatewayDispatchEvents.VoiceStateUpdate, GatewayDispatchEvents.VoiceServerUpdate,].includes(d.t)) return;
client.aqua.updateVoiceState(d);
});
client.on("messageCreate", async (message) => {
if (message.author.bot) return;
if (!message.content.startsWith("!play")) return;
const query = message.content.slice(6);
const player = client.aqua.createConnection({
guildId: message.guild.id,
voiceChannel: message.member.voice.channel.id,
textChannel: message.channel.id,
deaf: true,
});
const resolve = await client.aqua.resolve({ query, requester: message.member });
if (resolve.loadType === 'playlist') {
await message.channel.send(`Added ${resolve.tracks.length} songs from ${resolve.playlistInfo.name} playlist.`);
player.queue.add(resolve.tracks);
if (!player.playing && !player.paused) return player.play();
} else if (resolve.loadType === 'search' || resolve.loadType === 'track') {
const track = resolve.tracks.shift();
track.info.requester = message.member;
player.queue.add(track);
await message.channel.send(`Added **${track.info.title}** to the queue.`);
if (!player.playing && !player.paused) return player.play();
} else {
return message.channel.send(`There were no results found for your query.`);
}
});
client.aqua.on("nodeConnect", (node) => {
console.log(`Node connected: ${node.name}`);
});
client.aqua.on("nodeError", (node, error) => {
console.log(`Node "${node.name}" encountered an error: ${error.message}.`);
});
client.login("Yourtokenhere");