2.0.0 โ€ข Published 17 days ago

shunko v2.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
17 days ago

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.

2.0.0

17 days ago

1.0.1

6 months ago

1.0.0

6 months ago