Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shoukaku

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shoukaku

A lavalink client for Discord.js v12 only

  • 1.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1K
decreased by-15.81%
Maintainers
1
Weekly downloads
 
Created
Source

Shoukaku

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

The ShipGirl Project, feat Shoukaku (<=) & Zuikaku (=>) (c) Kancolle for our cute girls

✅ Currently being used by:

DBL

Why Shoukaku?

✅ Straightforward.

✅ Maintained.

✅ Reliable.

✅ Stable.

✅ Feature-rich.

✅ Very cute and reliable Shipgirl ❤ (Very Very Important)

Documentation

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

Installation

For Stable

npm i shoukaku

For Master

npm i Deivu/Shoukaku

Changelogs

You can view it on CHANGELOGS.MD file in this repository.

Support Server

Join in ShipGirls Community and ask at #support channel.

Issues or Bugs

Feel free to open an issue in the Issues section of this repository.

View Lavalink README here

Example on a fully functional Discord Bot

Serves as your guide on how I implement my own library

View Kongou's source code here

Really simple example of using this

const { Client } = require('discord.js');
const { Shoukaku } = require('shoukaku');

const LavalinkServer = [{ name: 'Localhost', host: 'localhost', port: 6969, auth: 'big_weeb' }];
const ShoukakuOptions = { moveOnDisconnect: false, resumable: false, resumableTimeout: 30, reconnectTries: 2, restTimeout: 10000 };

class ExampleBot extends Client {
    constructor(opts) {
        super(opts);
        this.shoukaku = new Shoukaku(this, LavalinkServer, ShoukakuOptions);
    }

    login(token) {
        this._setupShoukakuEvents();
        this._setupClientEvents();
        return super.login(token);
    }

    _setupShoukakuEvents() {
        this.shoukaku.on('ready', (name) => console.log(`Lavalink Node: ${name} is now connected`));
        // You must handle error event
        this.shoukaku.on('error', (name, error) => console.log(`Lavalink Node: ${name} emitted an error.`, error));
        this.shoukaku.on('close', (name, code, reason) => console.log(`Lavalink Node: ${name} closed with code ${code}. Reason: ${reason || 'No reason'}`));
        this.shoukaku.on('disconnected', (name, reason) => console.log(`Lavalink Node: ${name} disconnected. Reason: ${reason || 'No reason'}`));
    }

    _setupClientEvents() {
        this.on('message', async (msg) => {
            if (msg.author.bot || !msg.guild) return;
            if (!msg.content.startsWith('$play')) return;
            if (this.shoukaku.getPlayer(msg.guild.id)) return;
            const args = msg.content.split(' ');
            if (!args[1]) return;
            const node = this.shoukaku.getNode();
            let data = await node.rest.resolve(args[1]);
            if (!data) return;
            const player = await node.joinVoiceChannel({
                guildID: msg.guild.id,
                voiceChannelID: msg.member.voice.channelID
            });
            const cleanFunction = (param) => {
                console.log(param);
                player.disconnect();
            }
            player.on('end', cleanFunction);
            player.on('closed', cleanFunction);
            player.on('error', cleanFunction);
            player.on('nodeDisconnect', cleanFunction);
            await player.playTrack(data.tracks.shift()); // can also be "data.tracks.shift().track but that looks meme here since playTrack also accepts an instance of ShoukakuTrack
            await msg.channel.send("Now Playing: " + data.info.title);
        });
        this.on('ready', () => console.log('Bot is now ready'));
    }
}

new ExampleBot()
    .login('token')
    .catch(console.error);

Keywords

FAQs

Package last updated on 17 Apr 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc