3.3.23 • Published 11 months ago

mikuni-shoukaku v3.3.23

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Shoukaku

A stable and updated wrapper around Lavalink

Discord npm Github Stars GitHub issues Snyk Vulnerabilities for npm package NPM

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

npm install shoukaku

Documentation

https://deivu.github.io/Shoukaku/

Small code snippet examples

Initializing the library (Using Connector Discord.JS)

const { Client } = require('discord.js');
const { Shoukaku, Connectors } = require('shoukaku');
const Nodes = [{
    name: 'Localhost',
    url: 'localhost:6969',
    auth: 'marin_kitagawa'
}];
const client = new Client();
const shoukaku = new Shoukaku(new Connectors.DiscordJS(client), Nodes);
// ALWAYS handle error, logging it will do
shoukaku.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 it
client.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 INITIALIZE
client.on('ready', () => {
    client.shoukaku = new Shoukaku(new Connectors.DiscordJS(client), Nodes);
});

Searching and joining a channel (Async Function Implementation)

const node = shoukaku.getNode();
if (!node) return;
const result = await node.rest.resolve('scsearch:snowhalation');
if (!result?.tracks.length) return;
const metadata = result.tracks.shift();
const player = await node.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)

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

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 milliseconds
restTimeoutnumberTime to wait for a response from the Lavalink REST API before giving up in milliseconds
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)

Creating Plugins

Shoukaku has now official supports for plugins. However, implementing this is up to the developers that is interested on doing it

Shoukaku support modification on Rest.ts and Player.ts

To apply your plugin, put the extended classes on ShoukakuOptions.structures. Example below

const { Client } = require('discord.js');
const { Shoukaku, Rest, Connectors } = require('shoukaku');
class CustomRest extends Rest { }; // extended structure of your choice
const Nodes = [{
    name: 'Localhost',
    url: 'localhost:6969',
    auth: 'marin_kitagawa'
}];
const ShoukakuOptions = { structures: { rest: CustomRest } } // pass the custom structure to Shoukaku
const client = new Client();
const shoukaku = new Shoukaku(new Connectors.DiscordJS(client), Nodes, ShoukakuOptions);

Other Links

Support (#Development) | Lavalink

Implementation (Discord.JS)

Kongou

Made with ❤ by

@Sāya#0113

3.3.13

11 months ago

3.3.14

11 months ago

3.3.15

11 months ago

3.3.16

11 months ago

3.3.17

11 months ago

3.3.18

11 months ago

3.3.19

11 months ago

3.3.12

11 months ago

3.3.20

11 months ago

3.3.21

11 months ago

3.3.22

11 months ago

3.3.23

11 months ago

3.3.11

1 year ago

3.3.10

1 year ago

3.3.9

1 year ago

3.3.8

1 year ago

3.3.7

1 year ago

3.3.6

1 year ago

3.3.5

1 year ago

3.3.4

1 year ago

3.3.3

1 year ago

3.3.2

1 year ago

3.3.1

1 year ago