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

shunko

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shunko

A powerful lavalink wrapper around shoukaku

  • 2.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Discord npm version npm download GitHub issues

🎶 Shunko

A Simple but powerful Lavalink Client for your JavaScript Discord Bot!

🔨 Requirements

  • Node.js >= 16.9.0 or Latest.
  • Discord.js >= 14.6.0.

📖 Documentation

Updates

  • Shunko v2 now supports Lavalink version 4.

📦 How to Install Shunko

Stable: "npm i npm i shunko"

How to Setup our Shunko

Set the Initilizer of Shunko

Creating in a way like the code example you can import the bot, nodes and shoukakuOptions.

const { Client, GatewayIntentBits } = require("discord.js");
const { Shunko } = require("shunko");
const { Connectors } = require("shoukaku");

const client = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.GuildVoiceStates,
        GatewayIntentBits.MessageContent
    ],
});


client.shunko = new Shunko({
    nodes: [{
      name: "Lavalink",
      url: "localhost:2333",
      auth: "youshallpass",
      secure: false
    }],
    shoukakuoptions: {
        moveOnDisconnect: false,
        resumable: false,
        resumableTimeout: 60,
        reconnectTries: 10,
        restTimeout: 60000
    },
    spotify: [{
        ClientID: "Your spotify clientId here",
        ClientSecret: "Your spotify clientSecret here"
    }],
    defaultSearchEngine: "ShunkoSpotify",
}, new Connectors.DiscordJS(client));

client.login("token");

A small example to create play command.

module.exports = {
   name: "play",
   aliases: ["p"],
   run: async (client, message, args) => {
   
const player = await client.shunko.createPlayer({
    guildId: message.guild.id,
    voiceId: message.member.voice.channel.id,
    textId: message.channel.id,
    shardId: message.guild.shardId,
    volume: 100,
    deaf: true,
});

const resolve = await player.search(args.join(" "));
const { loadType, tracks, playlistInfo } = resolve;

if (loadType === "NO_MATCHES" || !tracks.length) return message.reply({content: "No match songs result found!"});

if (loadType === "PLAYLIST_LOADED") {
    for (const track of tracks) {
        player.queue.add(track, { requester: message.author });
    }
    if (!player.playing && !player.paused) await player.play();
    message.channel.send({ content: `Added ${player.queue.length} tracks from ${playlistInfo.name}` });
} else if (loadType === "SEARCH_RESULT" || loadType === "TRACK_LOADED") {
    player.queue.add(tracks[0], { requester: message.author });
    if (!player.playing && !player.paused) await player.play();
    message.channel.send({ content: `Queued ${tracks[0].info.title}` });
} else return;
  }
}

Getting the Events (shoukaku)

You can access event with the help of client.shunko.shoukaku.on().....

Event NameElementsDescription
readyname, resumedEvent of the node connection.
errorname, errorEvent of the node error.
closename, code, reasonEvent of the node close.
disconnectname, players, moveEvent of the node disconnect.
debugname, reasonEvent of the node debug.

Getting the Events (Shunko)

You can access event with the help of client.shunko.on().....

Event NameElementsDescription
trackStartplayer, trackEvent of the track start.
trackEndplayer, trackEvent of the track end.
queueEndplayerEvent of the queue end.
PlayerClosedplayer, dataEvent of the player close.
trackExceptionplayer, dataEvent of the track exception.
PlayerUpdateplayer, dataEvent of the player update.
trackStuckplayer, dataEvent of the track stuck.
trackErrorplayer, errorEvent of the track error.
PlayerResumedplayerEvent of the player resumed.
PlayerDestroyplayerEvent of the player destroyed.
PlayerCreateplayerEvent of the player create.

Donations 🧡🧡

You can donate to us to improve our project!

"Buy Me A Coffee"

Contributors

Deivu as the owner of Shoukaku.

Matrix as a helper for this package.

Ichigo Kurosaki as owner of this package.

Keywords

FAQs

Package last updated on 23 May 2024

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