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

magmastream

Package Overview
Dependencies
Maintainers
0
Versions
53
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.6.0 to 2.6.1

45

dist/index.d.ts

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Message, User, ClientUser } from 'discord.js';

@@ -206,2 +205,4 @@ import WebSocket from 'ws';

isAutoplay: boolean;
/** The number of times to try autoplay before emitting queueEnd. */
autoplayTries: number;
private static _manager;

@@ -275,3 +276,3 @@ private readonly data;

*/
setAutoplay(autoplayState: boolean, botUser: object): this;
setAutoplay(autoplayState: boolean, botUser: object, tries?: number): this;
/**

@@ -916,5 +917,5 @@ * Gets recommended tracks and returns an array of tracks.

* Initiates the Manager.
* @param clientId
* @param clientId - The Discord client ID (required).
*/
init(clientId?: string): this;
init(clientId: string): this;
/**

@@ -1014,3 +1015,19 @@ * Searches the enabled sources based off the URL or the `source` property.

}
type SearchPlatform = "deezer" | "soundcloud" | "youtube music" | "youtube" | "spotify" | "jiosaavn" | "tidal" | "applemusic" | "bandcamp";
declare const UseNodeOptions: {
readonly leastLoad: "leastLoad";
readonly leastPlayers: "leastPlayers";
};
type UseNodeOption = keyof typeof UseNodeOptions;
declare const SearchPlatforms: {
readonly deezer: "deezer";
readonly soundcloud: "soundcloud";
readonly "youtube music": "youtube music";
readonly youtube: "youtube";
readonly spotify: "spotify";
readonly jiosaavn: "jiosaavn";
readonly tidal: "tidal";
readonly applemusic: "applemusic";
readonly bandcamp: "bandcamp";
};
type SearchPlatform = keyof typeof SearchPlatforms;
type PlayerStateEventType = "connectionChange" | "playerCreate" | "playerDestroy" | "channelChange" | "volumeChange" | "pauseChange" | "queueChange" | "trackChange" | "repeatChange" | "autoplayChange";

@@ -1045,5 +1062,21 @@ interface SearchQuery {

}
interface PlaylistInfoData {
/** Url to playlist. */
url: string;
/** Type is always playlist in that case. */
type: string;
/** ArtworkUrl of playlist */
artworkUrl: string;
/** Number of total tracks in playlist */
totalTracks: number;
/** Author of playlist */
author: string;
}
interface PlaylistData {
/** The playlist name. */
name: string;
/** Requester of playlist. */
requester: User | ClientUser;
/** More playlist information. */
playlistInfo: PlaylistInfoData[];
/** The length of the playlist. */

@@ -1083,2 +1116,2 @@ duration: number;

export { type CPUStats, type EqualizerBand, type Exception, type Extendable, type FrameStats, type LavalinkInfo, type LavalinkResponse, type LoadType, Manager, type ManagerEvents, type ManagerOptions, type MemoryStats, Node, type NodeMessage, type NodeOptions, type NodeStats, type Payload, type PlayOptions, Player, type PlayerEvent, type PlayerEventType, type PlayerEvents, type PlayerOptions, type PlayerStateEventType, type PlayerUpdate, type PlaylistData, type PlaylistRawData, Plugin, Queue, type SearchPlatform, type SearchQuery, type SearchResult, type Severity, type Sizes, type SponsorBlockChapterStarted, type SponsorBlockChaptersLoaded, type SponsorBlockSegment, type SponsorBlockSegmentEventType, type SponsorBlockSegmentEvents, type SponsorBlockSegmentSkipped, type SponsorBlockSegmentsLoaded, type State, Structure, type Track, type TrackData, type TrackDataInfo, type TrackEndEvent, type TrackEndReason, type TrackExceptionEvent, type TrackPluginInfo, type TrackSourceName, type TrackStartEvent, type TrackStuckEvent, TrackUtils, type UnresolvedQuery, type UnresolvedTrack, type VoicePacket, type VoiceServer, type VoiceState, type WebSocketClosedEvent, validSponsorBlocks };
export { type CPUStats, type EqualizerBand, type Exception, type Extendable, type FrameStats, type LavalinkInfo, type LavalinkResponse, type LoadType, Manager, type ManagerEvents, type ManagerOptions, type MemoryStats, Node, type NodeMessage, type NodeOptions, type NodeStats, type Payload, type PlayOptions, Player, type PlayerEvent, type PlayerEventType, type PlayerEvents, type PlayerOptions, type PlayerStateEventType, type PlayerUpdate, type PlaylistData, type PlaylistInfoData, type PlaylistRawData, Plugin, Queue, type SearchPlatform, SearchPlatforms, type SearchQuery, type SearchResult, type Severity, type Sizes, type SponsorBlockChapterStarted, type SponsorBlockChaptersLoaded, type SponsorBlockSegment, type SponsorBlockSegmentEventType, type SponsorBlockSegmentEvents, type SponsorBlockSegmentSkipped, type SponsorBlockSegmentsLoaded, type State, Structure, type Track, type TrackData, type TrackDataInfo, type TrackEndEvent, type TrackEndReason, type TrackExceptionEvent, type TrackPluginInfo, type TrackSourceName, type TrackStartEvent, type TrackStuckEvent, TrackUtils, type UnresolvedQuery, type UnresolvedTrack, type UseNodeOption, UseNodeOptions, type VoicePacket, type VoiceServer, type VoiceState, type WebSocketClosedEvent, validSponsorBlocks };

37

dist/structures/Manager.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Manager = void 0;
exports.SearchPlatforms = exports.UseNodeOptions = exports.Manager = void 0;
const tslib_1 = require("tslib");

@@ -340,13 +340,15 @@ /* eslint-disable no-async-promise-executor */

* Initiates the Manager.
* @param clientId
* @param clientId - The Discord client ID (required).
*/
init(clientId) {
if (this.initiated)
if (this.initiated) {
return this;
if (typeof clientId !== "undefined")
this.options.clientId = clientId;
if (typeof this.options.clientId !== "string")
throw new Error('"clientId" set is not type of "string"');
if (!this.options.clientId)
throw new Error('"clientId" is not set. Pass it in Manager#init() or as a option in the constructor.');
}
// Validate clientId
if (typeof clientId !== "string" || !/^\d+$/.test(clientId)) {
throw new Error('"clientId" must be a valid Discord client ID.');
}
// Set the validated clientId
this.options.clientId = clientId;
// Attempt to connect nodes
for (const node of this.nodes.values()) {

@@ -404,2 +406,4 @@ try {

name: playlistData.info.name,
playlistInfo: playlistData.pluginInfo,
requester: requester,
tracks: playlistData.tracks.map((track) => Utils_1.TrackUtils.build(track, requester)),

@@ -615,1 +619,16 @@ duration: playlistData.tracks.reduce((acc, cur) => acc + (cur.info.length || 0), 0),

exports.Manager = Manager;
exports.UseNodeOptions = {
leastLoad: "leastLoad",
leastPlayers: "leastPlayers",
};
exports.SearchPlatforms = {
deezer: "deezer",
soundcloud: "soundcloud",
"youtube music": "youtube music",
youtube: "youtube",
spotify: "spotify",
jiosaavn: "jiosaavn",
tidal: "tidal",
applemusic: "applemusic",
bandcamp: "bandcamp",
};

@@ -371,4 +371,4 @@ "use strict";

// Handle autoplay
async handleAutoplay(player, track, attempts = 0) {
if (!player.isAutoplay || attempts > 3 || !player.queue.previous)
async handleAutoplay(player, track, attempt = 0) {
if (!player.isAutoplay || attempt === player.autoplayTries || !player.queue.previous)
return false;

@@ -381,3 +381,4 @@ const previousTrack = player.queue.previous;

// Handle YouTube autoplay logic
if ((!apiKey && this.info.sourceManagers.includes("youtube")) || (attempts > 2 && this.info.sourceManagers.includes("youtube"))) {
if ((!apiKey && this.info.sourceManagers.includes("youtube")) ||
(attempt === player.autoplayTries - 1 && !(apiKey && player.autoplayTries === 1) && this.info.sourceManagers.includes("youtube"))) {
const hasYouTubeURL = ["youtube.com", "youtu.be"].some((url) => previousTrack.uri.includes(url));

@@ -522,3 +523,3 @@ const videoID = hasYouTubeURL

let success = false;
while (attempts <= 3) {
while (attempts <= player.autoplayTries) {
success = await this.handleAutoplay(player, track, attempts);

@@ -525,0 +526,0 @@ if (success)

@@ -50,2 +50,4 @@ "use strict";

isAutoplay = false;
/** The number of times to try autoplay before emitting queueEnd. */
autoplayTries = 3;
static _manager;

@@ -120,3 +122,3 @@ data = {};

this.state = "CONNECTING";
const oldPlayer = { ...this };
const oldPlayer = this ? { ...this } : null;
this.manager.options.send(this.guild, {

@@ -140,3 +142,3 @@ op: 4,

this.state = "DISCONNECTING";
const oldPlayer = { ...this };
const oldPlayer = this ? { ...this } : null;
this.pause(true);

@@ -159,3 +161,3 @@ this.manager.options.send(this.guild, {

destroy(disconnect = true) {
const oldPlayer = { ...this };
const oldPlayer = this ? { ...this } : null;
this.state = "DESTROYING";

@@ -177,6 +179,6 @@ if (disconnect) {

throw new TypeError("Channel must be a non-empty string.");
const oldPlayer = { ...this };
const oldPlayer = this ? { ...this } : null;
this.voiceChannel = channel;
this.connect();
this.manager.emit("playerStateUpdate", oldPlayer, this, "channelChange");
this.manager.emit("playerStateUpdate", oldPlayer, this, "voiceChannelChange");
return this;

@@ -191,5 +193,5 @@ }

throw new TypeError("Channel must be a non-empty string.");
const oldPlayer = { ...this };
const oldPlayer = this ? { ...this } : null;
this.textChannel = channel;
this.manager.emit("playerStateUpdate", oldPlayer, this, "channelChange");
this.manager.emit("playerStateUpdate", oldPlayer, this, "textChannelChange");
return this;

@@ -243,3 +245,3 @@ }

*/
setAutoplay(autoplayState, botUser) {
setAutoplay(autoplayState, botUser, tries = 3) {
if (typeof autoplayState !== "boolean") {

@@ -251,4 +253,8 @@ throw new TypeError("autoplayState must be a boolean.");

}
const oldPlayer = { ...this };
if (typeof tries !== "number" || tries < 1) {
tries = 3; // Default to 3 if invalid
}
const oldPlayer = this ? { ...this } : null;
this.isAutoplay = autoplayState;
this.autoplayTries = tries;
this.set("Internal_BotUser", botUser);

@@ -335,3 +341,3 @@ this.manager.emit("playerStateUpdate", oldPlayer, this, "autoplayChange");

throw new TypeError("Volume must be a number.");
const oldPlayer = { ...this };
const oldPlayer = this ? { ...this } : null;
this.node.rest.updatePlayer({

@@ -373,3 +379,3 @@ guildId: this.options.guild,

throw new TypeError('Repeat can only be "true" or "false".');
const oldPlayer = { ...this };
const oldPlayer = this ? { ...this } : null;
if (repeat) {

@@ -385,3 +391,3 @@ this.trackRepeat = true;

}
this.manager.emit("playerStateUpdate", oldPlayer, this, "repeatChange");
this.manager.emit("playerStateUpdate", oldPlayer, this, "trackRepeatChange");
return this;

@@ -396,3 +402,3 @@ }

throw new TypeError('Repeat can only be "true" or "false".');
const oldPlayer = { ...this };
const oldPlayer = this ? { ...this } : null;
if (repeat) {

@@ -408,3 +414,3 @@ this.trackRepeat = false;

}
this.manager.emit("playerStateUpdate", oldPlayer, this, "repeatChange");
this.manager.emit("playerStateUpdate", oldPlayer, this, "queueRepeatChange");
return this;

@@ -424,3 +430,3 @@ }

}
const oldPlayer = { ...this };
const oldPlayer = this ? { ...this } : null;
if (repeat) {

@@ -446,3 +452,3 @@ this.trackRepeat = false;

}
this.manager.emit("playerStateUpdate", oldPlayer, this, "repeatChange");
this.manager.emit("playerStateUpdate", oldPlayer, this, "dynamicRepeatChange");
return this;

@@ -467,3 +473,3 @@ }

stop(amount) {
const oldPlayer = { ...this };
const oldPlayer = this ? { ...this } : null;
if (typeof amount === "number" && amount > 1) {

@@ -480,3 +486,3 @@ if (amount > this.queue.length)

});
this.manager.emit("playerStateUpdate", oldPlayer, this, "trackChange");
this.manager.emit("playerStateUpdate", oldPlayer, this, "trackChangeStop");
return this;

@@ -493,3 +499,3 @@ }

return this;
const oldPlayer = { ...this };
const oldPlayer = this ? { ...this } : null;
this.playing = !pause;

@@ -508,6 +514,6 @@ this.paused = pause;

previous() {
const oldPlayer = { ...this };
const oldPlayer = this ? { ...this } : null;
this.queue.unshift(this.queue.previous);
this.stop();
this.manager.emit("playerStateUpdate", oldPlayer, this, "trackChange");
this.manager.emit("playerStateUpdate", oldPlayer, this, "trackChangePrevious");
return this;

@@ -526,3 +532,3 @@ }

}
const oldPlayer = { ...this };
const oldPlayer = this ? { ...this } : null;
if (position < 0 || position > this.queue.current.duration)

@@ -537,3 +543,3 @@ position = Math.max(Math.min(position, this.queue.current.duration), 0);

});
this.manager.emit("playerStateUpdate", oldPlayer, this, "trackChange");
this.manager.emit("playerStateUpdate", oldPlayer, this, "trackChangeSeek");
return this;

@@ -540,0 +546,0 @@ }

@@ -43,3 +43,3 @@ "use strict";

this.manager.emit("debug", `[QUEUE] Added ${Array.isArray(track) ? track.length : 1} track(s) to queue: ${trackInfo}`);
const oldPlayer = { ...this.manager.players.get(this.guild) };
const oldPlayer = this.manager.players.get(this.guild) ? { ...this.manager.players.get(this.guild) } : null;
if (!Utils_1.TrackUtils.validate(track)) {

@@ -81,6 +81,6 @@ throw new RangeError('Track must be a "Track" or "Track[]".');

}
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), "queueChange");
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), "queueTrackAdd");
}
remove(startOrPosition = 0, end) {
const oldPlayer = { ...this.manager.players.get(this.guild) };
const oldPlayer = this.manager.players.get(this.guild) ? { ...this.manager.players.get(this.guild) } : null;
if (typeof end !== "undefined") {

@@ -96,3 +96,3 @@ // Validate input for `start` and `end`

this.manager.emit("debug", `[QUEUE] Removed ${removedTracks.length} track(s) from player: ${this.guild} from position ${startOrPosition} to ${end}.`);
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), "queueChange");
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), "queueTrackRemove");
return;

@@ -103,3 +103,3 @@ }

this.manager.emit("debug", `[QUEUE] Removed 1 track from player: ${this.guild} from position ${startOrPosition}: ${JSON.stringify(removedTrack[0], null, 2)}`);
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), "queueChange");
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), "queueTrackRemoveSingle");
return;

@@ -109,5 +109,5 @@ }

clear() {
const oldPlayer = { ...this.manager.players.get(this.guild) };
const oldPlayer = this.manager.players.get(this.guild) ? { ...this.manager.players.get(this.guild) } : null;
this.splice(0);
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), "queueChange");
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), "queueClear");
this.manager.emit("debug", `[QUEUE] Cleared the queue for: ${this.guild}`);

@@ -117,3 +117,3 @@ }

shuffle() {
const oldPlayer = { ...this.manager.players.get(this.guild) };
const oldPlayer = this.manager.players.get(this.guild) ? { ...this.manager.players.get(this.guild) } : null;
for (let i = this.length - 1; i > 0; i--) {

@@ -123,7 +123,7 @@ const j = Math.floor(Math.random() * (i + 1));

}
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), "queueChange");
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), "queueShuffle");
this.manager.emit("debug", `[QUEUE] Shuffled the queue for: ${this.guild}`);
}
userBlockShuffle() {
const oldPlayer = { ...this.manager.players.get(this.guild) };
const oldPlayer = this.manager.players.get(this.guild) ? { ...this.manager.players.get(this.guild) } : null;
const userTracks = new Map();

@@ -148,7 +148,7 @@ this.forEach((track) => {

this.add(shuffledQueue);
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), "queueChange");
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), "queueUserBlockShuffle");
this.manager.emit("debug", `[QUEUE] userBlockShuffled the queue for: ${this.guild}`);
}
roundRobinShuffle() {
const oldPlayer = { ...this.manager.players.get(this.guild) };
const oldPlayer = this.manager.players.get(this.guild) ? { ...this.manager.players.get(this.guild) } : null;
const userTracks = new Map();

@@ -182,3 +182,3 @@ this.forEach((track) => {

this.add(shuffledQueue);
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), "queueChange");
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), "queueRobinShuffle");
this.manager.emit("debug", `[QUEUE] roundRobinShuffled the queue for: ${this.guild}`);

@@ -185,0 +185,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = managerCheck;
const Manager_1 = require("../structures/Manager");
function managerCheck(options) {
if (!options)
throw new TypeError("ManagerOptions must not be empty.");
const { autoPlay, clientId, clientName, defaultSearchPlatform, nodes, plugins, send, trackPartial, usePriority, useNode, replaceYouTubeCredentials, lastFmApiKey, } = options;
if (typeof autoPlay !== "undefined" && typeof autoPlay !== "boolean") {
const { autoPlay, clientName, defaultSearchPlatform, nodes, plugins, send, trackPartial, usePriority, useNode, replaceYouTubeCredentials, lastFmApiKey } = options;
if (typeof autoPlay !== "boolean") {
throw new TypeError('Manager option "autoPlay" must be a boolean.');
}
if (typeof clientId !== "undefined" && !/^\d+$/.test(clientId)) {
throw new TypeError('Manager option "clientId" must be a non-empty string.');
if (typeof clientName !== "undefined") {
if (typeof clientName !== "string" || clientName.trim().length === 0) {
throw new TypeError('Manager option "clientName" must be a non-empty string.');
}
}
if (typeof clientName !== "undefined" && typeof clientName !== "string") {
throw new TypeError('Manager option "clientName" must be a string.');
if (typeof defaultSearchPlatform !== "undefined") {
if (typeof defaultSearchPlatform !== "string" || !Object.values(Manager_1.SearchPlatforms).includes(defaultSearchPlatform)) {
throw new TypeError(`Manager option "defaultSearchPlatform" must be one of: ${Object.values(Manager_1.SearchPlatforms).join(", ")}.`);
}
}
if (typeof defaultSearchPlatform !== "undefined" && typeof defaultSearchPlatform !== "string") {
throw new TypeError('Manager option "defaultSearchPlatform" must be a string.');
}
if (typeof nodes !== "undefined" && !Array.isArray(nodes)) {
if (typeof nodes === "undefined" || !Array.isArray(nodes)) {
throw new TypeError('Manager option "nodes" must be an array.');

@@ -28,4 +31,9 @@ }

}
if (typeof trackPartial !== "undefined" && !Array.isArray(trackPartial)) {
throw new TypeError('Manager option "trackPartial" must be a string array.');
if (typeof trackPartial !== "undefined") {
if (!Array.isArray(trackPartial)) {
throw new TypeError('Manager option "trackPartial" must be an array.');
}
if (!trackPartial.every(item => typeof item === "string")) {
throw new TypeError('Manager option "trackPartial" must be an array of strings.');
}
}

@@ -37,4 +45,4 @@ if (typeof usePriority !== "undefined" && typeof usePriority !== "boolean") {

for (let index = 0; index < nodes.length; index++) {
if (!nodes[index].priority) {
throw new TypeError(`Missing node option "priority" at position ${index}`);
if (typeof nodes[index].priority !== 'number' || isNaN(nodes[index].priority)) {
throw new TypeError(`Missing or invalid node option "priority" at position ${index}`);
}

@@ -47,4 +55,4 @@ }

}
if (useNode !== "leastLoad" && useNode !== "leastPlayers") {
throw new TypeError('Manager option must be either "leastLoad" or "leastPlayers".');
if (!(useNode in Manager_1.UseNodeOptions)) {
throw new TypeError('Manager option "useNode" must be either "leastLoad" or "leastPlayers".');
}

@@ -56,5 +64,4 @@ }

if (typeof lastFmApiKey !== "undefined" && (typeof lastFmApiKey !== "string" || lastFmApiKey.trim().length === 0)) {
throw new TypeError('Manager option "lastFmApiKey" must be a string.');
throw new TypeError('Manager option "lastFmApiKey" must be a non-empty string.');
}
}
exports.default = managerCheck;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = nodeCheck;
function nodeCheck(options) {

@@ -41,2 +42,1 @@ if (!options)

}
exports.default = nodeCheck;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = playerCheck;
function playerCheck(options) {

@@ -29,2 +30,1 @@ if (!options)

}
exports.default = playerCheck;
{
"name": "magmastream",
"version": "2.6.0",
"version": "2.6.1",
"description": "A user-friendly Lavalink client designed for NodeJS.",

@@ -18,4 +18,4 @@ "main": "dist/index.js",

"@favware/rollup-type-bundler": "^3.3.0",
"@types/lodash": "^4.17.13",
"@types/node": "^20.17.9",
"@types/lodash": "^4.17.14",
"@types/node": "^20.17.12",
"@types/ws": "^8.5.13",

@@ -26,5 +26,5 @@ "@typescript-eslint/eslint-plugin": "^7.18.0",

"npm-run-all": "^4.1.5",
"typedoc": "^0.25.13",
"typedoc-plugin-no-inherit": "^1.4.0",
"typescript": "^5.4.5"
"typedoc": "^0.27.6",
"typedoc-plugin-no-inherit": "^1.5.0",
"typescript": "^5.7.3"
},

@@ -31,0 +31,0 @@ "dependencies": {

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