Socket
Socket
Sign inDemoInstall

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 - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

2

package.json
{
"name": "shoukaku",
"version": "2.0.2",
"version": "2.0.3",
"description": "A lavalink wrapper that supports almost all libraries",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -137,3 +137,3 @@ const EventEmitter = require('events');

*/
playTrack(input, options = {}) {
playTrack(input, options = { }) {
if (!input) throw new Error('No track given to play');

@@ -441,5 +441,5 @@ if (input instanceof ShoukakuTrack) input = input.track;

_onPlayerEvent(json) {
this.position = 0;
switch (json.type) {
case 'TrackStartEvent':
this.position = 0;
this.emit('start', json);

@@ -456,5 +456,5 @@ break;

if (this.connection.reconnecting) break;
if (this.connection.moved)
if (this.connection.moved)
this.connection.moved = !this.connection.moved;
else
else
this.emit('closed', json);

@@ -468,2 +468,3 @@ break;

);
break;
}

@@ -470,0 +471,0 @@ }

@@ -168,3 +168,3 @@ const EventEmitter = require('events');

this.ws = new Websocket(this.url, { headers });
this.ws.once('upgrade', response => this.ws.once('open', () => this._open(response)));
this.ws.once('upgrade', response => this.ws.once('open', () => this._open(response, reconnect)));
this.ws.once('close', (...args) => this._close(...args));

@@ -207,3 +207,3 @@ this.ws.on('error', error => this.emit('error', this.name, error));

*/
async joinChannel(options = {}) {
async joinChannel(options = { }) {
if (isNaN(options.shardId) || !options.guildId || !options.channelId)

@@ -213,3 +213,3 @@ throw new Error('Supplied options needs to have a "guildId", "shardId", and "channelId" properties');

throw new Error('This node is not yet ready');
if (!this.shoukaku.library.guilds.has(options.guildId))
if (!this.shoukaku.library.guilds.has(options.guildId))
throw new Error('Guild could\'t be found, cannot continue creating this connection');

@@ -251,6 +251,8 @@ try {

* @param {Object} response
* @param {boolean} [reconnect=false]
* @returns {void}
* @private
*/
_open(response) {
_open(response, reconnect = false) {
const resumed = response.headers['session-resumed'] === 'true';
this.queue.process();

@@ -264,7 +266,17 @@ if (this.resumable) {

}
if (!resumed && reconnect) {
for (const player of [...this.players.values()]) {
player.connection.node.send({
op: 'voiceUpdate',
guildId: player.connection.guildId,
sessionId: player.connection.sessionId,
event: player.connection.serverUpdate
});
player.resume();
}
}
this.reconnects = 0;
this.state = state.CONNECTED;
const resumed = response.headers['session-resumed'] === 'true';
this.emit('debug', this.name, `[Socket] <-> [${this.name}] : Connection Open ${this.url} | Resumed: ${resumed}`);
this.emit('ready', this.name, resumed);
this.emit('debug', this.name, `[Socket] <-> [${this.name}] : Connection Open ${this.url} | Resumed: ${!resumed && reconnect ? reconnect : resumed}`);
this.emit('ready', this.name, !resumed && reconnect ? reconnect : resumed);
}

@@ -328,9 +340,8 @@ /**

const players = [...this.players.values()];
const moved = this.moveOnDisconnect && this.shoukaku.nodes.size > 0;
if (moved)
for (const player of players) player.moveNode(this.shoukaku._getIdeal(this.group));
else
for (const player of players) player.connection.disconnect();
const moved = this.moveOnDisconnect && this.shoukaku.nodes.size > 1;
for (const player of players) {
moved ? player.moveNode(this.shoukaku._getIdeal(this.group).name) : player.connection.disconnect();
}
this.queue.clear();
this.emit('disconnect', this.name, players, moved);
this.emit('disconnect', this.name, players, players.length > 0 && moved);
}

@@ -337,0 +348,0 @@ /**

@@ -41,3 +41,3 @@ import { EventEmitter } from 'events';

public send(data: Object, important: boolean): void;
private _open(response: Object): void;
private _open(response: Object, reconnect?: boolean): void;
private _message(message: string): void;

@@ -44,0 +44,0 @@ private _close(code: number, reason: string): void;

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