Skip to content

Repository files navigation

Shoukaku

A stable and updated wrapper around Lavalink

DiscordnpmGithub StarsGitHub issuesSnyk Vulnerabilities for npm packageNPM

The ShipGirl Project, feat Shoukaku; ⓒ Kancolle

Features

✅ Stable

✅ Documented

✅ Updated

✅ Extendable

✅ ESM & CommonJS supported

✅ Very cute (Very Important)

Supported Libraries

Refer to /src/connectors for list of supported libraries + how to support other libraries

Installation

  • Stable (3.x.x) (Needs Lavalink Versions: 3.5.x < | 3.9.x >)

npm install shoukaku

  • Dev (4.0.0-dev) (Needs Lavalink Versions: 3.7.x <)

For living on the edge but with latest features: npm install https://github.com/Deivu/Shoukaku.git#v4

Dev versions are not guaranteed to stay the same api wise, and even with last known stable, I won't say it's 100% stable

Documentation

https://deivu.github.io/Shoukaku/ (Stable v3 version only)

https://github.com/Deivu/Shoukaku/tree/v3 (v3 stable github branch)

v4.x.x docs are in your intellisense for now (I only deploy stable release docs on the Github page)

Small code snippet examples

Initializing the library (Using Connector Discord.JS)

const{ Client }=require('discord.js');const{ Shoukaku, Connectors }=require('shoukaku');constNodes=[{name: 'Localhost',url: 'localhost:6969',auth: 'marin_kitagawa'}];constclient=newClient();constshoukaku=newShoukaku(newConnectors.DiscordJS(client),Nodes);// ALWAYS handle error, logging it will doshoukaku.on('error',(_,error)=>console.error(error));client.login('token');// If you want shoukaku to be available on client, then bind it to it, here is one example of itclient.shoukaku=shoukaku;

Never initialize Shoukaku like this, or else she will never initialize, start shoukaku before you call client.login()

// NEVER DO THIS, OR SHOUKAKU WILL NEVER INITIALIZEclient.on('ready',()=>{client.shoukaku=newShoukaku(newConnectors.DiscordJS(client),Nodes);});

Searching and joining a channel (Async Function Implementation)

constnode=shoukaku.getNode();if(!node)return;constresult=awaitnode.rest.resolve('scsearch:snowhalation');if(!result?.tracks.length)return;constmetadata=result.tracks.shift();constplayer=awaitnode.joinChannel({guildId: 'your_guild_id',channelId: 'your_channel_id',shardId: 0// if unsharded it will always be zero (depending on your library implementation)});// player is created and ready, do your thing

Playing a track and changing a playback option (in this example, volume)

awaitplayer.playTrack({track: metadata.encodedTrack});awaitplayer.setVolume(0.5);

Updating the whole player if you don't want to use my helper functions

awaitplayer.update({ ...playerOptions});

Shoukaku's options

OptionTypeDescription
resumebooleanWhether to resume a connection on disconnect to Lavalink (Server Side) (Note: DOES NOT RESUME WHEN THE LAVALINK SERVER DIES)
resumeKeystringResume key for Lavalink
resumeTimeoutnumberTimeout before resuming a connection in seconds
resumeByLibrarybooleanWhether to resume the players by doing it in the library side (Client Side) (Note: TRIES TO RESUME REGARDLESS OF WHAT HAPPENED ON A LAVALINK SERVER)
alwaysSendResumeKeybooleanDisables the first time initialization tracking of nodes, and just sends the resume key always (Note: Useful for people who save their players to redis and wants to resume sessions even at first boot)
reconnectTriesnumberNumber of times to try and reconnect to Lavalink before giving up
reconnectIntervalnumberTimeout before trying to reconnect in seconds
restTimeoutnumberTime to wait for a response from the Lavalink REST API before giving up in seconds
moveOnDisconnectbooleanWhether to move players to a different Lavalink node when a node disconnects
userAgentstringUser Agent to use when making requests to Lavalink
structuresObject{rest?, player?}Custom structures for shoukaku to use

Plugins list

Open a pr to add your plugin here

NameLinkDescription
KazagumoGithubA Shoukaku wrapper that have built-in queue system
stone-deezerNPMA plugin to simplify deezer links and then play it from available sources (REQUIRES KAZAGUMO)

Other Links

Support (#Development) | Lavalink

Implementation (Discord.JS)

Kongou

Made with ❤ by

@Sāya#0113

About

A stable, powerful and updated wrapper around Lavalink

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages