New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

magmastream

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

magmastream - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

24

dist/index.d.ts
/// <reference types="node" />
import { Pool } from 'undici';
import WebSocket from 'ws';

@@ -383,6 +382,6 @@ import { Collection } from '@discordjs/collection';

private request;
get(endpoint: RouteLike): Promise<unknown>;
patch(endpoint: RouteLike, body: unknown): Promise<unknown>;
post(endpoint: RouteLike, body: unknown): Promise<unknown>;
delete(endpoint: RouteLike): Promise<unknown>;
get(endpoint: string): Promise<unknown>;
patch(endpoint: string, body: unknown): Promise<unknown>;
post(endpoint: string, body: unknown): Promise<unknown>;
delete(endpoint: string): Promise<unknown>;
}

@@ -409,3 +408,7 @@ interface playOptions {

/** voice payload. */
voice?: unknown;
voice?: {
token: string;
sessionId: string;
endpoint: string;
};
/** Whether to not replace the track if a play payload is sent. */

@@ -415,3 +418,2 @@ noReplace?: boolean;

}
type RouteLike = `/${string}`;

@@ -422,4 +424,2 @@ declare class Node {

socket: WebSocket | null;
/** The HTTP pool used for rest calls. */
http: Pool;
/** The amount of rest calls the node has made. */

@@ -486,4 +486,2 @@ calls: number;

requestTimeout?: number;
/** Options for the undici http pool used for http requests */
poolOptions?: Pool.Options;
}

@@ -601,3 +599,3 @@ interface NodeStats {

/** The track information. */
encoded?: string;
encoded: string;
/** The detailed information of the track. */

@@ -862,3 +860,3 @@ info: TrackDataInfo;

*/
updateVoiceState(data: VoicePacket | VoiceServer | VoiceState): void;
updateVoiceState(data: VoicePacket | VoiceServer | VoiceState): Promise<void>;
}

@@ -865,0 +863,0 @@ interface Payload {

@@ -120,18 +120,17 @@ "use strict";

*/
search(query, requester) {
return new Promise(async (resolve, reject) => {
const node = this.leastUsedNodes.first();
if (!node)
throw new Error("No available nodes.");
const _query = typeof query === "string" ? { query } : query;
const _source = Manager.DEFAULT_SOURCES[_query.source ?? this.options.defaultSearchPlatform] ?? _query.source;
let search = _query.query;
if (!/^https?:\/\//.test(search)) {
search = `${_source}:${search}`;
}
const res = (await node.rest
.get(`/v4/loadtracks?identifier=${encodeURIComponent(search)}`)
.catch((err) => reject(err)));
async search(query, requester) {
const node = this.leastUsedNodes.first();
if (!node) {
throw new Error("No available nodes.");
}
const _query = typeof query === "string" ? { query } : query;
const _source = Manager.DEFAULT_SOURCES[_query.source ?? this.options.defaultSearchPlatform] ?? _query.source;
let search = _query.query;
if (!/^https?:\/\//.test(search)) {
search = `${_source}:${search}`;
}
try {
const res = (await node.rest.get(`/v4/loadtracks?identifier=${encodeURIComponent(search)}`));
if (!res) {
return reject(new Error("Query not found."));
throw new Error("Query not found.");
}

@@ -149,16 +148,22 @@ let searchData = [];

playlistData = res.data;
break;
}
const tracks = searchData.map((track) => Utils_1.TrackUtils.build(track, requester));
const playlist = res.loadType === "playlist"
? {
name: playlistData.info.name,
tracks: playlistData.tracks.map((track) => Utils_1.TrackUtils.build(track, requester)),
duration: playlistData.tracks.reduce((acc, cur) => acc + (cur.info.length || 0), 0),
}
: null;
const result = {
loadType: res.loadType,
tracks: searchData.map((track) => Utils_1.TrackUtils.build(track, requester)) ?? [],
playlist: res.loadType === "playlist"
? {
name: playlistData.info.name,
tracks: playlistData.tracks.map((track) => Utils_1.TrackUtils.build(track, requester)) ?? [],
duration: playlistData.tracks.reduce((acc, cur) => acc + (cur.info.length || 0), 0),
}
: null,
tracks,
playlist,
};
return resolve(result);
});
return result;
}
catch (err) {
throw new Error(err);
}
}

@@ -240,12 +245,15 @@ /**

*/
updateVoiceState(data) {
async updateVoiceState(data) {
if ("t" in data &&
!["VOICE_STATE_UPDATE", "VOICE_SERVER_UPDATE"].includes(data.t))
!["VOICE_STATE_UPDATE", "VOICE_SERVER_UPDATE"].includes(data.t)) {
return;
}
const update = "d" in data ? data.d : data;
if (!update || (!("token" in update) && !("session_id" in update)))
if (!update || (!("token" in update) && !("session_id" in update))) {
return;
}
const player = this.players.get(update.guild_id);
if (!player)
if (!player) {
return;
}
if ("token" in update) {

@@ -278,3 +286,3 @@ /* voice server update */

const { sessionId, event: { token, endpoint }, } = player.voiceState;
player.node.rest.updatePlayer({
await player.node.rest.updatePlayer({
guildId: player.guild,

@@ -281,0 +289,0 @@ data: { voice: { token, endpoint, sessionId } },

@@ -7,3 +7,2 @@ "use strict";

const Utils_1 = require("./Utils");
const undici_1 = require("undici");
const Rest_1 = require("./Rest");

@@ -16,4 +15,2 @@ const nodeCheck_1 = tslib_1.__importDefault(require("../utils/nodeCheck"));

socket = null;
/** The HTTP pool used for rest calls. */
http;
/** The amount of rest calls the node has made. */

@@ -70,3 +67,2 @@ calls = 0;

}
this.http = new undici_1.Pool(`http${this.options.secure ? "s" : ""}://${this.address}`, this.options.poolOptions);
this.options.identifier = options.identifier || options.host;

@@ -73,0 +69,0 @@ this.stats = {

@@ -28,12 +28,12 @@ "use strict";

/** Retrieves all the players that are currently running on the node. */
getAllPlayers() {
return this.get(`/v4/sessions/${this.sessionId}/players`);
async getAllPlayers() {
return await this.get(`/v4/sessions/${this.sessionId}/players`);
}
/** Sends a PATCH request to update player related data. */
updatePlayer(options) {
return this.patch(`/v4/sessions/${this.sessionId}/players/${options.guildId}?noReplace=false`, options.data);
async updatePlayer(options) {
return await this.patch(`/v4/sessions/${this.sessionId}/players/${options.guildId}?noReplace=false`, options.data);
}
/** Sends a DELETE request to the server to destroy the player. */
destroyPlayer(guildId) {
return this.delete(`/v4/sessions/${this.sessionId}/players/${guildId}`);
async destroyPlayer(guildId) {
return await this.delete(`/v4/sessions/${this.sessionId}/players/${guildId}`);
}

@@ -40,0 +40,0 @@ /* Sends a GET request to the specified endpoint and returns the response data. */

{
"name": "magmastream",
"version": "2.0.4",
"version": "2.0.5",
"description": "A user-friendly Lavalink client designed for NodeJS.",

@@ -35,3 +35,2 @@ "main": "dist/index.js",

"tslib": "^2.4.0",
"undici": "^5.10.0",
"ws": "^8.8.1"

@@ -38,0 +37,0 @@ },

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