Skip to content

An Stable, performant, Recourse friendly and fast lavalink wrapper

Notifications You must be signed in to change notification settings

ToddyTheNoobDud/AquaLink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

Yay, Version 1.4.2 is released, wow

  • Rewrited CONNECTION manager (This fixes Bad request, Fixes sessionId, json responses from lavalink, and other bugfixes)
  • Fixed skip in Player, Fixed Destroy, Fixed desconnection, Fixed stop, And added some optimizations
  • Added clean this.voice on Aqua manager
  • Fixed Destroy sending embeds / text if there is an queue
  • Fixed stop / destroy sending all the texts (songs in queue)
  • Optimized the track handling

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");

Releases

No releases published

Packages

No packages published