Code Monkey home page Code Monkey logo

shoukaku's Introduction

Shoukaku

A stable and updated wrapper around Lavalink

Discord npm Github Stars GitHub issues NPM

Shoukaku, from Azur Lane, drawn by: @hoshimaro15

Features

  • Stable

  • Updated

  • Documented

  • Extendable

  • ESM & CommonJS supported

  • Very cute (Very Important)

Documentation

https://guide.shoukaku.shipgirl.moe/

Getting Started

https://guide.shoukaku.shipgirl.moe/guides/1-getting-started/

Supported Libraries

https://guide.shoukaku.shipgirl.moe/guides/5-connectors/

Example Bot

https://github.com/Deivu/Kongou

Configuration Options

// Parameters for main class init, Options is the Configuration Options
new Shoukaku(new Connectors.DiscordJS(client), Nodes, Options);
Option Type Default Description Notes
resume boolean false If you want to enable resuming when your connection when your connection to lavalink disconnects
resumeTimeout number 30 Timeout before lavalink destroys the players on a disconnect In seconds
resumeByLibrary boolean false If you want to force resume players no matter what even if it's not resumable by lavalink
reconnectTries number 3 Number of tries to reconnect to lavalink before disconnecting
reconnectInterval number 5 Timeout between reconnects In seconds
restTimeout number 60 Maximum amount of time to wait for rest lavalink api requests In seconds
moveOnDisconnect boolean false Whether to move players to a different lavalink node when a node disconnects
userAgent string (auto) Changes the user-agent used for lavalink requests Not recommeded to change
structures Object{rest?, player?} {} Custom structures for shoukaku to use
voiceConnectionTimeout number 15 Maximum amount of time to wait for a join voice channel command In seconds
nodeResolver function function Custom node resolver if you want to have your own method of getting the ideal node

Wrappers

Name Link Description
Kazagumo Github A wrapper for Shoukaku that has an internal queue system

Open a pr if you want to add a wrapper here

Other Links

Made with ❤ by @ichimakase (Saya)

The Shipgirl Project

shoukaku's People

Contributors

0t4u avatar 1conan avatar aadi0009 avatar allvaa avatar alpharyz3 avatar circeaurora avatar deivu avatar diced avatar evilg-mc avatar flav-code avatar freyacodes avatar ftrapture avatar github-actions[bot] avatar harusame3144 avatar itsmishra19 avatar kagchi avatar kakarot-dev avatar mirdukkk avatar nik9play avatar noxzym avatar sawa-ko avatar takase1121 avatar takiyo0 avatar thaddeuskkr avatar theferryn avatar tiltedkyoso avatar tysonop avatar uthsho avatar yimura avatar zerefdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shoukaku's Issues

TypeError this.resumable.split is not a function

tsc -p tsconfig.json
{
  "shoukaku": "Deivu/Shoukaku#master"
}
 TypeError  this.resumable.split is not a function
error stack:
• ShoukakuSocket.js:248 _open
    node_modules/shoukaku/src/node/ShoukakuSocket.js:248:81

• ShoukakuSocket.js:145 <anonymous>
    node_modules/shoukaku/src/node/ShoukakuSocket.js:145:41

• events.js:421 onceWrapper
    events.js:421:28

• events.js:315 emit
    events.js:315:20

• websocket.js:177 setSocket
    node_modules/ws/lib/websocket.js:177:10

• websocket.js:671 <anonymous>
    node_modules/ws/lib/websocket.js:671:15

• events.js:315 emit
    events.js:315:20

• _http_client.js:547 socketOnData
    _http_client.js:547:11

• events.js:315 emit
    events.js:315:20

question: player maximum volume

Re-post of the same unanswered post on Discord that I made a while ago.

On Shoukaku v4 (master), I've noticed that the maximum volume that can be set by the player is now 100. Why is it so?
Before this, the volume implementation was fine. Did something with Lavalink update that caused this change, or is it just a decision made by someone?

Asking because I don't think that the library should be limited in terms of a maximum volume, but rather the limits should be set by the various implementations.
https://github.com/Deivu/Shoukaku/blob/master/src/guild/Player.ts#L378-L385

No matches found using ytsearch with query including special characters

Description

Hi,

When using ytsearch with a query containing "é" or "à" or any "special" character, for exemple Annonces de Macron détaillées, députés accusés, trésor à 17 milliards d'€... Actus du jour, i get : No matches found and when looking at the request it replaces "é" with "Θ" for exemple, it replaces other special characters with other things too.

Error :

2022-06-25 23:58:07.312  INFO 13696 --- [  XNIO-1 task-1] l.server.player.AudioLoaderRestHandler   : Got request to load for identifier "ytsearch:Hugo DΘcrypte - Annonces de Macron dΘtaillΘes, dΘputΘs accusΘs, trΘsor α 17 milliards d'Ç... Actus du jour"
2022-06-25 23:58:07.533  INFO 13696 --- [ader-2-thread-1] lavalink.server.player.AudioLoader       : No matches found

Version info

Client used:
Shoukaku v3.1.0 (Latest)

Output of java -version:

java version "17.0.2" 2022-01-18 LTS
Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, sharing)

Output of java -jar Lavalink.jar --version:

Version:        4d005aa65d398ec9e494e9ea2f30221b3910b7df-SNAPSHOT
Build:          1365
Build time:     25.06.2022 13:57:44 UTC
Branch          master
Commit:         4d005aa
Commit time:    25.06.2022 13:52:17 UTC
JVM:            17.0.2
Lavaplayer      1.3.96-original

Improve The Documentation

I just want to say that improve the documentation because its very difficult to read. Rest your decision :)

PlayerOptions - startTime parameter isn't working

Hi, using this code :

const track_url = "QAAAhgIAIU5QQyByaWRlcyBoaXMgYmlrZSBpbnRvIHRoZSBtYXlvcgALTWVtZSBUeWNvb24AAAAAAAAfQAALMkpZSkY5TDVZVzQAAQAraHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj0ySllKRjlMNVlXNAAHeW91dHViZQAAAAAAAAAA"

await player.playTrack({
      track: track_url,
      startTime: 5
});

The video is 8 seconds long and i want it to start at five but it starts at the beggining whatever i do.
Have a nice day 👍

"Error: The voice connection is not established due to missing session id"

Hello,

I'm using the last version of Shoukaku (npm 3.2.2) with Node 18.12.1 and Lavalink (3.6.2), but when I'm using the node.joinChannel I've got this error:

Error: The voice connection is not established due to missing session id
    at Connection.connect (node_modules/shoukaku/src/guild/Connection.ts:161:27)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Node.joinChannel (node_modules/shoukaku/src/node/Node.ts:244:13)
    at MusicService.join (src/music/service.ts:92:20)

and on Lavalink side:

2022-12-16 18:20:33.934  INFO 37917 --- [  XNIO-1 I/O-12] lavalink.server.io.SocketServer          : Connection closed from /[0:0:0:0:0:0:0:1]:50349 -- CloseStatus[code=1006, reason=]
2022-12-16 18:20:33.935  INFO 37917 --- [  XNIO-1 I/O-12] lavalink.server.io.SocketContext         : Shutting down 0 playing players.

The bot is joining the channel, but there is no sound output.

I'm using this code (interaction var comes from an interaction with a slash command):

const shoukaku = new Shoukaku(
  new Connectors.DiscordJS(this.client.client),
  [{ name: 'Local', url: 'localhost:2333', auth: 'youshallnotpass' }],
);
shoukaku.on('error', (_, error) => console.error(error));

const node = shoukaku.getNode();
if (!node) return;
const result = await node.rest.resolve('ytsearch:never gonna give you up');
if (!result?.tracks.length) return;

const metadata = result.tracks.shift();
const channels = await interaction.guild.channels.fetch();
const channel = channels.find((channel) => {
  if (!(channel.type == ChannelType.GuildVoice)) return;
  return channel.members.find(
    (member) => member.user.id == interaction.member.user.id,
  );
});

if (!channel) return;

const player = await node.joinChannel({
  guildId: interaction.guildId,
  channelId: channel.id,
  shardId: 0,
});

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

Any idea why?

Error Code 1011

This error happens whenever I connect to the lavalink nodes. I don't really know what happens, but I used the same code as u did in the example.

No nodes

Hello,
I have this problem :

        const nodes = [
            {
                url: 'server.com:80',
                name: '1',
                auth: 'Password',
            }
        ]

        Success(`✅ Bot started: ${client.user.tag}!\n`);
        client.user.setActivity("Nice stream", {type: "STREAMING"});

        client.manager = new Shoukaku(new Connectors.DiscordJS(client), nodes);
        console.log(client.manager)
        client.manager.on('error', (_, error) => console.error(error));

And when I console.log(client.manager) :

  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  connector: DiscordJS {
    client: Client {
      _events: [Object: null prototype],
      _eventsCount: 8,
      _maxListeners: undefined,
      options: [Object],
      rest: [REST],
      ws: [WebSocketManager],
      actions: [ActionsManager],
      voice: [ClientVoiceManager],
      shard: null,
      users: UserManager {},
      guilds: GuildManager {},
      channels: ChannelManager {},
      sweepers: [Sweepers],
      presence: [ClientPresence],
      user: [ClientUser],
      application: [ClientApplication],
      readyTimestamp: 1664711493249,
      commands: [Collection [Map]],
      language: Collection(0) [Map] {},
      buttons: [Collection [Map]],
      modals: Collection(0) [Map] {},
      manager: [Circular *1],
      [Symbol(kCapture)]: true
    },
    manager: [Circular *1]
  },
  options: {
    resume: false,
    resumeKey: '[email protected](https://github.com/Deivu/Shoukaku)',
    resumeTimeout: 30000,
    resumeByLibrary: false,
    alwaysSendResumeKey: false,
    reconnectTries: 3,
    reconnectInterval: 5000,
    restTimeout: 60000,
    moveOnDisconnect: false,
    userAgent: 'shoukakubot/3.2.0 (https://github.com/Deivu/Shoukaku)',
    structures: {}
  },
  nodes: Map(0) {},
  id: null,
  [Symbol(kCapture)]: false
}```

Why I have 0 nodes ?
Thank for anwer.

Ascol57

Error: 404

Unexpected server response: 404

I'm running v4 Lavalink, and wrote exact certification, but code says it cannot connect to lavalink.

Deivu can you please add spotify support

hello sir,
it was to hard get metadata of track and play it through ytsearch. please deivu add spotify support through plugin please please please............ : (

your thanks,
unhappy shoukaku user with lots of sadness

Got error in my bot.

0|java  | 2022-08-27 11:43:11.867  INFO 26406 --- [  XNIO-1 task-8] l.server.player.AudioLoaderRestHandler   : Got request to load for identifier "ytmsearch:295"
0|java  | 2022-08-27 11:43:12.260  INFO 26406 --- [ader-2-thread-1] lavalink.server.player.AudioLoader       : Loaded playlist Search music results for: 295
1|index | SyntaxError: Unexpected token  in JSON at position 0
1|index |     at JSON.parse (<anonymous>)
1|index |     at ShoukakuRest.fetch (/home/ansh/Cosmic/node_modules/shoukaku/src/node/ShoukakuRest.js:112:21)
1|index |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
1|index |     at async ShoukakuRest.resolve (/home/ansh/Cosmic/node_modules/shoukaku/src/node/ShoukakuRest.js:50:22)
1|index |     at async kazagumoSearch.search (/home/ansh/Cosmic/node_modules/kazagumo/src/kazagumoSearch.js:48:24)
1|index |     at async kazagumoPlayer.search (/home/ansh/Cosmic/node_modules/kazagumo/src/kazagumoPlayer.js:161:16)
1|index |     at async playerhandler (/home/ansh/Cosmic/src/utils/functions.js:84:20)
1|index |     at async Object.run (/home/ansh/Cosmic/src/events/Client/setupSystem.js:42:9)
1|index | SyntaxError: Unexpected token  in JSON at position 0
1|index |     at JSON.parse (<anonymous>)
1|index |     at ShoukakuRest.fetch (/home/ansh/Cosmic/node_modules/shoukaku/src/node/ShoukakuRest.js:112:21)
1|index |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
1|index |     at async ShoukakuRest.resolve (/home/ansh/Cosmic/node_modules/shoukaku/src/node/ShoukakuRest.js:50:22)
1|index |     at async kazagumoSearch.search (/home/ansh/Cosmic/node_modules/kazagumo/src/kazagumoSearch.js:48:24)
1|index |     at async kazagumoPlayer.search (/home/ansh/Cosmic/node_modules/kazagumo/src/kazagumoPlayer.js:161:16)
1|index |     at async playerhandler (/home/ansh/Cosmic/src/utils/functions.js:84:20)
1|index |     at async Object.run (/home/ansh/Cosmic/src/events/Client/setupSystem.js:42:9) Promise {
1|index |   <rejected> SyntaxError: Unexpected token  in JSON at position 0
1|index |       at JSON.parse (<anonymous>)
1|index |       at ShoukakuRest.fetch (/home/ansh/Cosmic/node_modules/shoukaku/src/node/ShoukakuRest.js:112:21)
1|index |       at processTicksAndRejections (node:internal/process/task_queues:96:5)
1|index |       at async ShoukakuRest.resolve (/home/ansh/Cosmic/node_modules/shoukaku/src/node/ShoukakuRest.js:50:22)
1|index |       at async kazagumoSearch.search (/home/ansh/Cosmic/node_modules/kazagumo/src/kazagumoSearch.js:48:24)
1|index |       at async kazagumoPlayer.search (/home/ansh/Cosmic/node_modules/kazagumo/src/kazagumoPlayer.js:161:16)
1|index |       at async playerhandler (/home/ansh/Cosmic/src/utils/functions.js:84:20)
1|index |       at async Object.run (/home/ansh/Cosmic/src/events/Client/setupSystem.js:42:9)
1|index | }

Only one filter at once in v4

On v4 when I change filter by setRotation, setEqualizer etc. when other filter was set before this, it was reset and only new one was apply.

This same is when anyone filter was applied and volume was changed. Clear all filters and set volume.

Player ends playing song after around 15 seconds or so

initializing shoukaku with
import { Shoukaku, Connectors } from 'shoukaku';

`const Nodes = [
{
name: 'localhost',
url: 'localhost:2333',
auth: 'MyPassword',
},
];

const shoukaku = new Shoukaku(new Connectors.DiscordJS(client), Nodes);
`

all worked fine, until the bot randomly decided to leave the voice channel
after printing out the player.reason I got FINISHED, even though the song wasn't even halfway through

Lavalink: v3.7.7
Shoukaku: v3.4.0
Node.js: v18.17.0

Node connect

Why bot not working with 2 nodes like i add bot to 2 node after 4 to 5 hours player play but not hearing any sounds
and i try add 1 node it worked why is i can't add 2 nodes to bot

How to change region?

Hello!
How to change a player region in shoukaku?
In eris-lavalink i see this option, but in shoukaku docs could not find.

I get an error in the package types when I try to compile my typescript application

I am trying to compile my typescript application with the command tsc -p tsconfig.json but the compiler gives me the following error:

yarn run v1.22.5
$ tsc -p tsconfig.json
node_modules/shoukaku/index.d.ts:329:13 - error TS2300: Duplicate identifier 'serverUpdate'.

329     private serverUpdate: object | null;
                ~~~~~~~~~~~~

node_modules/shoukaku/index.d.ts:335:13 - error TS2300: Duplicate identifier 'serverUpdate'.

335     private serverUpdate(data: object);
                ~~~~~~~~~~~~


Found 2 errors.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

What appears to be an error in the types of this package.

can't auto move lavalink server

When playing some track and lavalink server disconnected from player, normally shoukaku trying to reconnect x attemps and move it to another lavalink server if not connected. but, the player is undefined when lavalink server disconnected from shoukaku, and get this error.
image

Trying to reconnected to lavalink server
image

Check the shoukaku player
image

And the second issue (maybe lavalink issue) is when shoukaku has been reconnected to lavalink server, bot not receive sound and only get this log from lavalink.
image
image

Also when track has been finished, shoukaku not emit track end event after moving lavalink server Fixed on #65

"PlayerStart" and "playerEnd" event on the client

It would be nice to have an event in the client called playerStart and playerEnd, and to be executed every time a guild player starts or ended.

I say this idea in order to better manage the control of players from one place.

Example:

const client = new Shoukaku(options);
client.on("playerStart", (guildId, player) => console.log(guildId, player));

client.on("playerEnd", (guildId, player) => console.log(guildId, player));

Spotify support

I am trying to play songs from Spotify but can't figure out how to go about implementing it. Can you please add Spotify support or give me some hints?

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('6')

| Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('3')
0|Greenbot | at new NodeError (node:internal/errors:371:5)
0|Greenbot | at ShoukakuHandler.emit (node:events:379:17)
0|Greenbot | at ShoukakuSocket. (/home/ubuntu/bots/green/node_modules/shoukaku/src/Shoukaku.js:1:680)
0|Greenbot | at ShoukakuSocket.emit (node:events:390:28)
0|Greenbot | at Object.callback (/home/ubuntu/bots/green/node_modules/shoukaku/src/node/ShoukakuQueue.js:1:440)
0|Greenbot | at callback (node:internal/streams/writable:552:21)
0|Greenbot | at onwriteError (node:internal/streams/writable:415:3)
0|Greenbot | at processTicksAndRejections (node:internal/process/task_queues:85:21) {
0|Greenbot | code: 'ERR_UNHANDLED_ERROR',
0|Greenbot | context: '3'
0|Greenbot | }

This error is happening after 20 hours only

TypeError: ShoukakuRest is not a constructor

Following code

const { Client } = require('discord.js')
const { Shoukaku, ShoukakuRest } = require('shoukaku')
const client = new Client()
const LavalinkServer = [{ name: 'Localhost', host: 'localhost', port: 2333, auth: 'pass' }]
const ShoukakuOptions = { moveOnDisconnect: false, resumable: false, resumableTimeout: 30, reconnectTries: 2, restTimeout: 10000 }
const shoukaku = new Shoukaku(client, LavalinkServer, ShoukakuOptions)
const rest = new ShoukakuRest("localhost", 2333, "pass", 10000)

client.login("token")

throws an error:

const rest = new ShoukakuRest("127.0.0.1", 2333, "youshallnotpass", 10000)
             ^

TypeError: ShoukakuRest is not a constructor
    at Object.<anonymous> (C:\Projects\test ds bot\index.js:11:14)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

Why? Shoukaku 1.4.2 and discordjs 12.2.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.