magmastream
Advanced tools
Comparing version 2.7.1 to 2.7.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PlayerStateEventTypes = exports.SearchPlatform = exports.UseNodeOptions = exports.Manager = void 0; | ||
exports.ManagerEventTypes = exports.PlayerStateEventTypes = exports.SearchPlatform = exports.UseNodeOptions = exports.Manager = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -339,5 +339,5 @@ /* eslint-disable no-async-promise-executor */ | ||
// The player state has been updated | ||
"playerStateUpdate", | ||
ManagerEventTypes.PlayerStateUpdate, | ||
// The player has been destroyed | ||
"playerDestroy", | ||
ManagerEventTypes.PlayerDestroy, | ||
]; | ||
@@ -504,9 +504,9 @@ // Register the events | ||
switch (res.loadType) { | ||
case "search": | ||
case Utils_1.LoadTypes.Search: | ||
searchData = res.data; | ||
break; | ||
case "track": | ||
case Utils_1.LoadTypes.Track: | ||
searchData = [res.data]; | ||
break; | ||
case "playlist": | ||
case Utils_1.LoadTypes.Playlist: | ||
playlistData = res.data; | ||
@@ -517,3 +517,3 @@ break; | ||
let playlist = null; | ||
if (res.loadType === "playlist") { | ||
if (res.loadType === Utils_1.LoadTypes.Playlist) { | ||
playlist = { | ||
@@ -542,3 +542,3 @@ name: playlistData.info.name, | ||
}; | ||
if (result.loadType === "playlist") { | ||
if (result.loadType === Utils_1.LoadTypes.Playlist) { | ||
result.playlist.tracks = result.playlist.tracks.map(processTrack); | ||
@@ -794,12 +794,41 @@ } | ||
(function (PlayerStateEventTypes) { | ||
PlayerStateEventTypes["AUTOPLAY_CHANGE"] = "playerAutoplay"; | ||
PlayerStateEventTypes["CONNECTION_CHANGE"] = "playerConnection"; | ||
PlayerStateEventTypes["REPEAT_CHANGE"] = "playerRepeat"; | ||
PlayerStateEventTypes["PAUSE_CHANGE"] = "playerPause"; | ||
PlayerStateEventTypes["PLAYER_CREATE"] = "playerCreate"; | ||
PlayerStateEventTypes["PLAYER_DESTROY"] = "playerDestroy"; | ||
PlayerStateEventTypes["QUEUE_CHANGE"] = "queueChange"; | ||
PlayerStateEventTypes["TRACK_CHANGE"] = "trackChange"; | ||
PlayerStateEventTypes["VOLUME_CHANGE"] = "volumeChange"; | ||
PlayerStateEventTypes["CHANNEL_CHANGE"] = "channelChange"; | ||
PlayerStateEventTypes["AutoPlayChange"] = "playerAutoplay"; | ||
PlayerStateEventTypes["ConnectionChange"] = "playerConnection"; | ||
PlayerStateEventTypes["RepeatChange"] = "playerRepeat"; | ||
PlayerStateEventTypes["PauseChange"] = "playerPause"; | ||
PlayerStateEventTypes["QueueChange"] = "queueChange"; | ||
PlayerStateEventTypes["TrackChange"] = "trackChange"; | ||
PlayerStateEventTypes["VolumeChange"] = "volumeChange"; | ||
PlayerStateEventTypes["ChannelChange"] = "channelChange"; | ||
PlayerStateEventTypes["PlayerCreate"] = "playerCreate"; | ||
PlayerStateEventTypes["PlayerDestroy"] = "playerDestroy"; | ||
})(PlayerStateEventTypes || (exports.PlayerStateEventTypes = PlayerStateEventTypes = {})); | ||
var ManagerEventTypes; | ||
(function (ManagerEventTypes) { | ||
ManagerEventTypes["Debug"] = "debug"; | ||
ManagerEventTypes["NodeCreate"] = "nodeCreate"; | ||
ManagerEventTypes["NodeDestroy"] = "nodeDestroy"; | ||
ManagerEventTypes["NodeConnect"] = "nodeConnect"; | ||
ManagerEventTypes["NodeReconnect"] = "nodeReconnect"; | ||
ManagerEventTypes["NodeDisconnect"] = "nodeDisconnect"; | ||
ManagerEventTypes["NodeError"] = "nodeError"; | ||
ManagerEventTypes["NodeRaw"] = "nodeRaw"; | ||
ManagerEventTypes["PlayerCreate"] = "playerCreate"; | ||
ManagerEventTypes["PlayerDestroy"] = "playerDestroy"; | ||
ManagerEventTypes["PlayerStateUpdate"] = "playerStateUpdate"; | ||
ManagerEventTypes["PlayerMove"] = "playerMove"; | ||
ManagerEventTypes["PlayerDisconnect"] = "playerDisconnect"; | ||
ManagerEventTypes["QueueEnd"] = "queueEnd"; | ||
ManagerEventTypes["SocketClosed"] = "socketClosed"; | ||
ManagerEventTypes["TrackStart"] = "trackStart"; | ||
ManagerEventTypes["TrackEnd"] = "trackEnd"; | ||
ManagerEventTypes["TrackEndReason"] = "trackEndReason"; | ||
ManagerEventTypes["TrackEndReasonRaw"] = "trackEndReasonRaw"; | ||
ManagerEventTypes["TrackEndReasonData"] = "trackEndReasonData"; | ||
ManagerEventTypes["TrackStuck"] = "trackStuck"; | ||
ManagerEventTypes["TrackError"] = "trackError"; | ||
ManagerEventTypes["SegmentsLoaded"] = "segmentsLoaded"; | ||
ManagerEventTypes["SegmentSkipped"] = "segmentSkipped"; | ||
ManagerEventTypes["ChapterStarted"] = "chapterStarted"; | ||
ManagerEventTypes["ChaptersLoaded"] = "chaptersLoaded"; | ||
})(ManagerEventTypes || (exports.ManagerEventTypes = ManagerEventTypes = {})); |
@@ -99,3 +99,3 @@ "use strict"; | ||
this.manager.nodes.set(this.options.identifier, this); | ||
this.manager.emit("nodeCreate", this); | ||
this.manager.emit(Manager_1.ManagerEventTypes.NodeCreate, this); | ||
this.rest = new Rest_1.Rest(this, this.manager); | ||
@@ -115,3 +115,3 @@ this.createSessionIdsFile(); | ||
if (!fs_1.default.existsSync(sessionIdsFilePath)) { | ||
this.manager.emit("debug", `[NODE] Creating sessionId file at: ${sessionIdsFilePath}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[NODE] Creating sessionId file at: ${sessionIdsFilePath}`); | ||
// Create the file with an empty object as the content | ||
@@ -129,3 +129,3 @@ fs_1.default.writeFileSync(sessionIdsFilePath, JSON.stringify({}), "utf-8"); | ||
// Emit a debug event indicating that session IDs are being loaded | ||
this.manager.emit("debug", `[NODE] Loading sessionIds from file: ${sessionIdsFilePath}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[NODE] Loading sessionIds from file: ${sessionIdsFilePath}`); | ||
// Read the content of the sessionIds.json file as a string | ||
@@ -145,3 +145,3 @@ const sessionIdsData = fs_1.default.readFileSync(sessionIdsFilePath, "utf-8"); | ||
// Emit a debug event indicating that the session IDs are being updated | ||
this.manager.emit("debug", `[NODE] Updating sessionIds to file: ${sessionIdsFilePath}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[NODE] Updating sessionIds to file: ${sessionIdsFilePath}`); | ||
// Update the session IDs Map with the new session ID | ||
@@ -192,3 +192,3 @@ sessionIdsMap.set(this.options.identifier, this.sessionId); | ||
}; | ||
this.manager.emit("debug", `[NODE] Connecting ${JSON.stringify(debugInfo)}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[NODE] Connecting ${JSON.stringify(debugInfo)}`); | ||
} | ||
@@ -218,3 +218,3 @@ /** | ||
}; | ||
this.manager.emit("debug", `[NODE] Destroying node: ${JSON.stringify(debugInfo)}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[NODE] Destroying node: ${JSON.stringify(debugInfo)}`); | ||
// Destroy all players connected to the node | ||
@@ -232,3 +232,3 @@ const players = this.manager.players.filter((p) => p.node == this); | ||
// Emit a "nodeDestroy" event with the node as the argument | ||
this.manager.emit("nodeDestroy", this); | ||
this.manager.emit(Manager_1.ManagerEventTypes.NodeDestroy, this); | ||
// Destroy the node from the manager | ||
@@ -254,3 +254,3 @@ this.manager.destroyNode(this.options.identifier); | ||
// Emit a debug event indicating the node is attempting to reconnect | ||
this.manager.emit("debug", `[NODE] Reconnecting node: ${JSON.stringify(debugInfo)}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[NODE] Reconnecting node: ${JSON.stringify(debugInfo)}`); | ||
// Schedule the reconnection attempt after the specified retry delay | ||
@@ -262,3 +262,3 @@ this.reconnectTimeout = setTimeout(() => { | ||
const error = new Error(`Unable to connect after ${this.options.retryAmount} attempts.`); | ||
this.manager.emit("nodeError", this, error); | ||
this.manager.emit(Manager_1.ManagerEventTypes.NodeError, this, error); | ||
return this.destroy(); | ||
@@ -270,3 +270,3 @@ } | ||
// Emit a nodeReconnect event and attempt to connect again | ||
this.manager.emit("nodeReconnect", this); | ||
this.manager.emit(Manager_1.ManagerEventTypes.NodeReconnect, this); | ||
this.connect(); | ||
@@ -295,5 +295,5 @@ // Increment the reconnect attempts counter | ||
// Emit a debug event indicating the node is connected | ||
this.manager.emit("debug", `[NODE] Connected node: ${JSON.stringify(debugInfo)}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[NODE] Connected node: ${JSON.stringify(debugInfo)}`); | ||
// Emit a "nodeConnect" event with the node as the argument | ||
this.manager.emit("nodeConnect", this); | ||
this.manager.emit(Manager_1.ManagerEventTypes.NodeConnect, this); | ||
} | ||
@@ -319,5 +319,5 @@ /** | ||
// Emit a "nodeDisconnect" event with the node and the close event as arguments | ||
this.manager.emit("nodeDisconnect", this, { code, reason }); | ||
this.manager.emit(Manager_1.ManagerEventTypes.NodeDisconnect, this, { code, reason }); | ||
// Emit a debug event indicating the node is disconnected | ||
this.manager.emit("debug", `[NODE] Disconnected node: ${JSON.stringify(debugInfo)}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[NODE] Disconnected node: ${JSON.stringify(debugInfo)}`); | ||
// If the close event was not initiated by the user, attempt to reconnect | ||
@@ -344,5 +344,5 @@ if (code !== 1000 || reason !== "destroy") | ||
// Emit a debug event indicating the error on the node | ||
this.manager.emit("debug", `[NODE] Error on node: ${JSON.stringify(debugInfo)}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[NODE] Error on node: ${JSON.stringify(debugInfo)}`); | ||
// Emit a "nodeError" event with the node and the error as arguments | ||
this.manager.emit("nodeError", this, error); | ||
this.manager.emit(Manager_1.ManagerEventTypes.NodeError, this, error); | ||
} | ||
@@ -361,3 +361,3 @@ /** | ||
return; | ||
this.manager.emit("nodeRaw", payload); | ||
this.manager.emit(Manager_1.ManagerEventTypes.NodeRaw, payload); | ||
let player; | ||
@@ -375,7 +375,7 @@ switch (payload.op) { | ||
case "event": | ||
this.manager.emit("debug", `[NODE] Node message: ${JSON.stringify(payload)}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[NODE] Node message: ${JSON.stringify(payload)}`); | ||
this.handleEvent(payload); | ||
break; | ||
case "ready": | ||
this.manager.emit("debug", `[NODE] Node message: ${JSON.stringify(payload)}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[NODE] Node message: ${JSON.stringify(payload)}`); | ||
this.rest.setSessionId(payload.sessionId); | ||
@@ -398,3 +398,3 @@ this.sessionId = payload.sessionId; | ||
default: | ||
this.manager.emit("nodeError", this, new Error(`Unexpected op "${payload.op}" with data: ${payload.message}`)); | ||
this.manager.emit(Manager_1.ManagerEventTypes.NodeError, this, new Error(`Unexpected op "${payload.op}" with data: ${payload.message}`)); | ||
return; | ||
@@ -451,3 +451,3 @@ } | ||
error = new Error(`Node#event unknown event '${type}'.`); | ||
this.manager.emit("nodeError", this, error); | ||
this.manager.emit(Manager_1.ManagerEventTypes.NodeError, this, error); | ||
break; | ||
@@ -467,5 +467,5 @@ } | ||
player.paused = false; | ||
this.manager.emit("trackStart", player, track, payload); | ||
this.manager.emit("playerStateUpdate", oldPlayer, player, { | ||
changeType: Manager_1.PlayerStateEventTypes.TRACK_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.TrackStart, player, track, payload); | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, player, { | ||
changeType: Manager_1.PlayerStateEventTypes.TrackChange, | ||
details: { | ||
@@ -498,3 +498,3 @@ changeType: "start", | ||
else if (reason === "replaced") { | ||
this.manager.emit("trackEnd", player, track, payload); | ||
this.manager.emit(Manager_1.ManagerEventTypes.TrackEnd, player, track, payload); | ||
player.queue.previous = player.queue.current; | ||
@@ -514,4 +514,4 @@ } | ||
} | ||
this.manager.emit("playerStateUpdate", oldPlayer, player, { | ||
changeType: Manager_1.PlayerStateEventTypes.TRACK_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, player, { | ||
changeType: Manager_1.PlayerStateEventTypes.TrackChange, | ||
details: { | ||
@@ -575,3 +575,3 @@ changeType: "end", | ||
const res = await player.search(searchURI, player.get("Internal_BotUser")); | ||
if (res.loadType === "empty" || res.loadType === "error") | ||
if (res.loadType === Utils_1.LoadTypes.Empty || res.loadType === Utils_1.LoadTypes.Error) | ||
return false; | ||
@@ -606,3 +606,3 @@ const foundTrack = res.tracks.find((t) => t.uri !== track.uri && t.author !== track.author && t.title !== track.title); | ||
const res = await player.search({ query: `${randomTrack.artist.name} - ${randomTrack.name}`, source: selectedSource }, player.get("Internal_BotUser")); | ||
if (res.loadType === "empty" || res.loadType === "error") | ||
if (res.loadType === Utils_1.LoadTypes.Empty || res.loadType === Utils_1.LoadTypes.Error) | ||
return false; | ||
@@ -625,3 +625,9 @@ const foundTrack = res.tracks.find((t) => t.uri !== track.uri); | ||
const url = `https://ws.audioscrobbler.com/2.0/?method=track.getSimilar&artist=${artist}&track=${title}&limit=10&autocorrect=1&api_key=${apiKey}&format=json`; | ||
const response = await axios_1.default.get(url); | ||
let response; | ||
try { | ||
response = await axios_1.default.get(url); | ||
} | ||
catch (error) { | ||
return false; | ||
} | ||
if (response.data.error || !response.data.similartracks?.track?.length) { | ||
@@ -634,3 +640,3 @@ const retryUrl = `https://ws.audioscrobbler.com/2.0/?method=artist.getTopTracks&artist=${artist}&autocorrect=1&api_key=${apiKey}&format=json`; | ||
const res = await player.search({ query: `${randomTrack.artist.name} - ${randomTrack.name}`, source: selectedSource }, player.get("Internal_BotUser")); | ||
if (res.loadType === "empty" || res.loadType === "error") | ||
if (res.loadType === Utils_1.LoadTypes.Empty || res.loadType === Utils_1.LoadTypes.Error) | ||
return false; | ||
@@ -646,3 +652,3 @@ const foundTrack = res.tracks.find((t) => t.uri !== track.uri); | ||
const res = await player.search({ query: `${randomTrack.artist.name} - ${randomTrack.name}`, source: selectedSource }, player.get("Internal_BotUser")); | ||
if (res.loadType === "empty" || res.loadType === "error") | ||
if (res.loadType === Utils_1.LoadTypes.Empty || res.loadType === Utils_1.LoadTypes.Error) | ||
return false; | ||
@@ -664,3 +670,3 @@ const foundTrack = res.tracks.find((t) => t.uri !== track.uri); | ||
} | ||
this.manager.emit("trackEnd", player, track, payload); | ||
this.manager.emit(Manager_1.ManagerEventTypes.TrackEnd, player, track, payload); | ||
if (this.manager.options.autoPlay) | ||
@@ -692,3 +698,3 @@ player.play(); | ||
// Emit the track end event | ||
this.manager.emit("trackEnd", player, track, payload); | ||
this.manager.emit(Manager_1.ManagerEventTypes.TrackEnd, player, track, payload); | ||
// If the track was stopped manually and there are no more tracks in the queue, end the queue | ||
@@ -720,3 +726,3 @@ if (payload.reason === "stopped" && !(queue.current = queue.shift())) { | ||
// Emit the track end event | ||
this.manager.emit("trackEnd", player, track, payload); | ||
this.manager.emit(Manager_1.ManagerEventTypes.TrackEnd, player, track, payload); | ||
// If autoplay is enabled, play the next track | ||
@@ -740,3 +746,3 @@ if (this.manager.options.autoPlay) | ||
player.playing = false; | ||
this.manager.emit("queueEnd", player, track, payload); | ||
this.manager.emit(Manager_1.ManagerEventTypes.QueueEnd, player, track, payload); | ||
return; | ||
@@ -755,3 +761,3 @@ } | ||
player.playing = false; | ||
this.manager.emit("queueEnd", player, track, payload); | ||
this.manager.emit(Manager_1.ManagerEventTypes.QueueEnd, player, track, payload); | ||
} | ||
@@ -770,3 +776,3 @@ /** | ||
player.stop(); | ||
this.manager.emit("trackStuck", player, track, payload); | ||
this.manager.emit(Manager_1.ManagerEventTypes.TrackStuck, player, track, payload); | ||
} | ||
@@ -785,3 +791,3 @@ /** | ||
player.stop(); | ||
this.manager.emit("trackError", player, track, payload); | ||
this.manager.emit(Manager_1.ManagerEventTypes.TrackError, player, track, payload); | ||
} | ||
@@ -795,4 +801,4 @@ /** | ||
socketClosed(player, payload) { | ||
this.manager.emit("socketClosed", player, payload); | ||
this.manager.emit("debug", `[NODE] Websocket closed for player: ${player.guild} with payload: ${JSON.stringify(payload)}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.SocketClosed, player, payload); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[NODE] Websocket closed for player: ${player.guild} with payload: ${JSON.stringify(payload)}`); | ||
} | ||
@@ -807,3 +813,3 @@ /** | ||
sponsorBlockSegmentLoaded(player, track, payload) { | ||
return this.manager.emit("segmentsLoaded", player, track, payload); | ||
return this.manager.emit(Manager_1.ManagerEventTypes.SegmentsLoaded, player, track, payload); | ||
} | ||
@@ -818,3 +824,3 @@ /** | ||
sponsorBlockSegmentSkipped(player, track, payload) { | ||
return this.manager.emit("segmentSkipped", player, track, payload); | ||
return this.manager.emit(Manager_1.ManagerEventTypes.SegmentSkipped, player, track, payload); | ||
} | ||
@@ -829,3 +835,3 @@ /** | ||
sponsorBlockChaptersLoaded(player, track, payload) { | ||
return this.manager.emit("chaptersLoaded", player, track, payload); | ||
return this.manager.emit(Manager_1.ManagerEventTypes.ChaptersLoaded, player, track, payload); | ||
} | ||
@@ -840,3 +846,3 @@ /** | ||
sponsorBlockChapterStarted(player, track, payload) { | ||
return this.manager.emit("chapterStarted", player, track, payload); | ||
return this.manager.emit(Manager_1.ManagerEventTypes.ChapterStarted, player, track, payload); | ||
} | ||
@@ -908,3 +914,3 @@ /** | ||
fs_1.default.writeFileSync(readmeFilePath, message, "utf-8"); | ||
this.manager.emit("debug", `[NODE] Created README file at: ${readmeFilePath}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[NODE] Created README file at: ${readmeFilePath}`); | ||
} | ||
@@ -911,0 +917,0 @@ } |
@@ -124,3 +124,3 @@ "use strict"; | ||
// Emit the playerCreate event. | ||
this.manager.emit("playerCreate", this); | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerCreate, this); | ||
// Set the initial volume. | ||
@@ -162,4 +162,4 @@ this.setVolume(options.volume ?? 100); | ||
// Emit the player state update event | ||
this.manager.emit("playerStateUpdate", oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.CONNECTION_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.ConnectionChange, | ||
details: { | ||
@@ -195,4 +195,4 @@ changeType: "connect", | ||
this.state = "DISCONNECTED"; | ||
this.manager.emit("playerStateUpdate", oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.CONNECTION_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.ConnectionChange, | ||
details: { | ||
@@ -221,6 +221,6 @@ changeType: "disconnect", | ||
this.node.rest.destroyPlayer(this.guild); | ||
this.manager.emit("playerDestroy", this); | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerDestroy, this); | ||
this.manager.players.delete(this.guild); | ||
this.manager.emit("playerStateUpdate", oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.PLAYER_DESTROY, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.PlayerDestroy, | ||
}); | ||
@@ -244,4 +244,4 @@ } | ||
// Emit a player state update event | ||
this.manager.emit("playerStateUpdate", oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.CHANNEL_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.ChannelChange, | ||
details: { | ||
@@ -274,4 +274,4 @@ changeType: "voice", | ||
// Emit a player state update event with channel change details | ||
this.manager.emit("playerStateUpdate", oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.CHANNEL_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.ChannelChange, | ||
details: { | ||
@@ -317,3 +317,3 @@ changeType: "text", | ||
catch (error) { | ||
this.manager.emit("trackError", this, this.queue.current, error); | ||
this.manager.emit(Manager_1.ManagerEventTypes.TrackError, this, this.queue.current, error); | ||
if (this.queue[0]) | ||
@@ -359,4 +359,4 @@ return this.play(this.queue[0]); | ||
this.set("Internal_BotUser", botUser); | ||
this.manager.emit("playerStateUpdate", oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.AUTOPLAY_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.AutoPlayChange, | ||
details: { | ||
@@ -429,6 +429,6 @@ previousAutoplay: oldPlayer.isAutoplay, | ||
const res = await this.manager.search(searchURI); | ||
if (res.loadType === "empty" || res.loadType === "error") | ||
if (res.loadType === Utils_1.LoadTypes.Empty || res.loadType === Utils_1.LoadTypes.Error) | ||
return; | ||
let tracks = res.tracks; | ||
if (res.loadType === "playlist") { | ||
if (res.loadType === Utils_1.LoadTypes.Playlist) { | ||
tracks = res.playlist.tracks; | ||
@@ -466,4 +466,4 @@ } | ||
this.volume = volume; | ||
this.manager.emit("playerStateUpdate", oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.VOLUME_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.VolumeChange, | ||
details: { previousVolume: oldPlayer.volume || null, currentVolume: this.volume }, | ||
@@ -523,4 +523,4 @@ }); | ||
// Emit an event indicating the repeat mode has changed | ||
this.manager.emit("playerStateUpdate", oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.REPEAT_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.RepeatChange, | ||
detail: { | ||
@@ -558,4 +558,4 @@ changeType: "track", | ||
// Emit the player state update event | ||
this.manager.emit("playerStateUpdate", oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.REPEAT_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.RepeatChange, | ||
detail: { | ||
@@ -614,4 +614,4 @@ changeType: "queue", | ||
// Emit a player state update event | ||
this.manager.emit("playerStateUpdate", oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.REPEAT_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.RepeatChange, | ||
detail: { | ||
@@ -675,4 +675,4 @@ changeType: "dynamic", | ||
}); | ||
this.manager.emit("playerStateUpdate", oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.QUEUE_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.QueueChange, | ||
details: { | ||
@@ -710,4 +710,4 @@ changeType: "remove", | ||
// Emit an event indicating the pause state has changed. | ||
this.manager.emit("playerStateUpdate", oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.PAUSE_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.PauseChange, | ||
details: { | ||
@@ -732,4 +732,4 @@ previousPause: oldPlayer.paused, | ||
// Emit a player state update event indicating the track change to previous. | ||
this.manager.emit("playerStateUpdate", oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.TRACK_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.TrackChange, | ||
details: { | ||
@@ -772,4 +772,4 @@ changeType: "previous", | ||
// Emit an event to notify the manager of the track change. | ||
this.manager.emit("playerStateUpdate", oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.TRACK_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, { | ||
changeType: Manager_1.PlayerStateEventTypes.TrackChange, | ||
details: { | ||
@@ -776,0 +776,0 @@ changeType: "timeUpdate", |
@@ -65,3 +65,3 @@ "use strict"; | ||
// Emit a debug message | ||
this.manager.emit("debug", `[QUEUE] Added ${Array.isArray(track) ? track.length : 1} track(s) to queue: ${trackInfo}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[QUEUE] Added ${Array.isArray(track) ? track.length : 1} track(s) to queue: ${trackInfo}`); | ||
const oldPlayer = this.manager.players.get(this.guild) ? { ...this.manager.players.get(this.guild) } : null; | ||
@@ -115,4 +115,4 @@ // Validate the track | ||
// Emit a player state update event with the added track(s) | ||
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), { | ||
changeType: Manager_1.PlayerStateEventTypes.QUEUE_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guild), { | ||
changeType: Manager_1.PlayerStateEventTypes.QueueChange, | ||
details: { | ||
@@ -135,5 +135,5 @@ changeType: "add", | ||
const removedTracks = this.splice(startOrPosition, end - startOrPosition); | ||
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), { | ||
changeType: Manager_1.PlayerStateEventTypes.QUEUE_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[QUEUE] Removed ${removedTracks.length} track(s) from player: ${this.guild} from position ${startOrPosition} to ${end}.`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guild), { | ||
changeType: Manager_1.PlayerStateEventTypes.QueueChange, | ||
details: { | ||
@@ -148,7 +148,7 @@ changeType: "remove", | ||
const removedTrack = this.splice(startOrPosition, 1); | ||
this.manager.emit("debug", `[QUEUE] Removed 1 track from player: ${this.guild} from position ${startOrPosition}: ${JSON.stringify(removedTrack[0], null, 2)}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[QUEUE] Removed 1 track from player: ${this.guild} from position ${startOrPosition}: ${JSON.stringify(removedTrack[0], null, 2)}`); | ||
// Ensure removedTrack is an array for consistency | ||
const tracksToEmit = removedTrack.length > 0 ? removedTrack : []; | ||
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), { | ||
changeType: Manager_1.PlayerStateEventTypes.QUEUE_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guild), { | ||
changeType: Manager_1.PlayerStateEventTypes.QueueChange, | ||
details: { | ||
@@ -171,4 +171,4 @@ changeType: "remove", | ||
// Emit an event to update the player state indicating the queue has been cleared. | ||
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), { | ||
changeType: Manager_1.PlayerStateEventTypes.QUEUE_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guild), { | ||
changeType: Manager_1.PlayerStateEventTypes.QueueChange, | ||
details: { | ||
@@ -180,3 +180,3 @@ changeType: "clear", | ||
// Emit a debug message indicating the queue has been cleared for a specific guild. | ||
this.manager.emit("debug", `[QUEUE] Cleared the queue for: ${this.guild}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[QUEUE] Cleared the queue for: ${this.guild}`); | ||
} | ||
@@ -196,4 +196,4 @@ /** | ||
// Emit an event to update the player state indicating the queue has been shuffled. | ||
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), { | ||
changeType: Manager_1.PlayerStateEventTypes.QUEUE_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guild), { | ||
changeType: Manager_1.PlayerStateEventTypes.QueueChange, | ||
details: { | ||
@@ -204,3 +204,3 @@ changeType: "shuffle", | ||
// Emit a debug message indicating the queue has been shuffled for a specific guild. | ||
this.manager.emit("debug", `[QUEUE] Shuffled the queue for: ${this.guild}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[QUEUE] Shuffled the queue for: ${this.guild}`); | ||
} | ||
@@ -238,4 +238,4 @@ /** | ||
// Emit an event to update the player state indicating the queue has been shuffled. | ||
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), { | ||
changeType: Manager_1.PlayerStateEventTypes.QUEUE_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guild), { | ||
changeType: Manager_1.PlayerStateEventTypes.QueueChange, | ||
details: { | ||
@@ -246,3 +246,3 @@ changeType: "userBlock", | ||
// Emit a debug message indicating the queue has been shuffled for a specific guild. | ||
this.manager.emit("debug", `[QUEUE] userBlockShuffled the queue for: ${this.guild}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[QUEUE] userBlockShuffled the queue for: ${this.guild}`); | ||
} | ||
@@ -288,4 +288,4 @@ /** | ||
// Emit an event to update the player state indicating the queue has been shuffled. | ||
this.manager.emit("playerStateUpdate", oldPlayer, this.manager.players.get(this.guild), { | ||
changeType: Manager_1.PlayerStateEventTypes.QUEUE_CHANGE, | ||
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guild), { | ||
changeType: Manager_1.PlayerStateEventTypes.QueueChange, | ||
details: { | ||
@@ -296,5 +296,5 @@ changeType: "roundRobin", | ||
// Emit a debug message indicating the queue has been shuffled for a specific guild. | ||
this.manager.emit("debug", `[QUEUE] roundRobinShuffled the queue for: ${this.guild}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[QUEUE] roundRobinShuffled the queue for: ${this.guild}`); | ||
} | ||
} | ||
exports.Queue = Queue; |
@@ -6,2 +6,3 @@ "use strict"; | ||
const axios_1 = tslib_1.__importDefault(require("axios")); | ||
const Manager_1 = require("./Manager"); | ||
/** Handles the requests sent to the Lavalink REST API. */ | ||
@@ -44,3 +45,3 @@ class Rest { | ||
// Log the result of the request. | ||
this.manager.emit("debug", `[REST] Getting all players on node: ${this.node.options.identifier} : ${JSON.stringify(result)}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[REST] Getting all players on node: ${this.node.options.identifier} : ${JSON.stringify(result)}`); | ||
// Return the result of the request. | ||
@@ -56,3 +57,3 @@ return result; | ||
// Log the request. | ||
this.manager.emit("debug", `[REST] Updating player: ${options.guildId}: ${JSON.stringify(options)}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[REST] Updating player: ${options.guildId}: ${JSON.stringify(options)}`); | ||
// Send the PATCH request. | ||
@@ -68,3 +69,3 @@ return await this.patch(`/v4/sessions/${this.sessionId}/players/${options.guildId}?noReplace=false`, options.data); | ||
// Log the request. | ||
this.manager.emit("debug", `[REST] Destroying player: ${guildId}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[REST] Destroying player: ${guildId}`); | ||
// Send the DELETE request. | ||
@@ -83,3 +84,3 @@ return await this.delete(`/v4/sessions/${this.sessionId}/players/${guildId}`); | ||
// Emit a debug event with information about the session being updated | ||
this.manager.emit("debug", `[REST] Updating session: ${this.sessionId}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[REST] Updating session: ${this.sessionId}`); | ||
// Send a PATCH request to update the session with the provided resuming status and timeout | ||
@@ -96,3 +97,3 @@ return await this.patch(`/v4/sessions/${this.sessionId}`, { resuming, timeout }); | ||
async request(method, endpoint, body) { | ||
this.manager.emit("debug", `[REST] ${method} api call for endpoint: ${endpoint} with data: ${JSON.stringify(body)}`); | ||
this.manager.emit(Manager_1.ManagerEventTypes.Debug, `[REST] ${method} api call for endpoint: ${endpoint} with data: ${JSON.stringify(body)}`); | ||
const config = { | ||
@@ -99,0 +100,0 @@ method, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Plugin = exports.Structure = exports.TrackUtils = void 0; | ||
exports.LoadTypes = exports.Plugin = exports.Structure = exports.TrackUtils = void 0; | ||
/** @hidden */ | ||
@@ -266,1 +266,9 @@ const TRACK_SYMBOL = Symbol("track"), | ||
}; | ||
var LoadTypes; | ||
(function (LoadTypes) { | ||
LoadTypes["Track"] = "track"; | ||
LoadTypes["Playlist"] = "playlist"; | ||
LoadTypes["Search"] = "search"; | ||
LoadTypes["Empty"] = "empty"; | ||
LoadTypes["Error"] = "error"; | ||
})(LoadTypes || (exports.LoadTypes = LoadTypes = {})); |
{ | ||
"name": "magmastream", | ||
"version": "2.7.1", | ||
"version": "2.7.2", | ||
"description": "A user-friendly Lavalink client designed for NodeJS.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
266082
5904