Skip to content

Commit

Permalink
Cleaned up debug event
Browse files Browse the repository at this point in the history
- Fixed circular reference
- Cleaned up more logging
  • Loading branch information
Vexify4103 committed Oct 27, 2024
1 parent 9f22fc7 commit aa6c0c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/structures/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export class Manager extends EventEmitter {
volume: lavaPlayer.volume || state.options.volume,
};

this.emit("debug", `[MANAGER] Recreating player: ${state.guild} from saved file: ${JSON.stringify(state.options)}`);
const player = this.create(playerOptions);

if (!lavaPlayer.state.connected) {
Expand Down Expand Up @@ -443,7 +444,7 @@ export class Manager extends EventEmitter {
search = `${_source}:${search}`;
}

this.emit("debug", `[MANAGER] Performing ${_source} search for: ${_query}`);
this.emit("debug", `[MANAGER] Performing ${_source} search for: ${_query.query}`);

try {
const res = (await node.rest.get(`/v4/loadtracks?identifier=${encodeURIComponent(search)}`)) as LavalinkResponse;
Expand Down Expand Up @@ -505,7 +506,7 @@ export class Manager extends EventEmitter {
}
}

this.emit("debug", `[MANAGER] Result ${_source} search for: ${_query}: ${JSON.stringify(result)}`);
this.emit("debug", `[MANAGER] Result ${_source} search for: ${_query.query}: ${JSON.stringify(result)}`);
return result;
} catch (err) {
throw new Error(err);
Expand Down Expand Up @@ -677,14 +678,14 @@ export class Manager extends EventEmitter {
public async updateVoiceState(data: VoicePacket | VoiceServer | VoiceState): Promise<void> {
if ("t" in data && !["VOICE_STATE_UPDATE", "VOICE_SERVER_UPDATE"].includes(data.t)) return;

this.emit("debug", `[MANAGER] Updating voice state: ${JSON.stringify(data)}`);
const update = "d" in data ? data.d : data;

if (!update || (!("token" in update) && !("session_id" in update))) return;

const player = this.players.get(update.guild_id);

if (!player) return;
this.emit("debug", `[MANAGER] Updating voice state: ${JSON.stringify(update)}`);
if ("token" in update) {
player.voiceState.event = update;

Expand Down
5 changes: 3 additions & 2 deletions src/structures/Rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ export class Rest {

/** Retrieves all the players that are currently running on the node. */
public async getAllPlayers(): Promise<unknown> {
this.manager.emit("debug", `[REST] Getting all players for: ${JSON.stringify(this.node)}`);
return await this.get(`/v4/sessions/${this.sessionId}/players`);
const result = await this.get(`/v4/sessions/${this.sessionId}/players`);
this.manager.emit("debug", `[REST] Getting all players on node: ${this.node.options.identifier} : ${JSON.stringify(result)}`);
return result;
}

/** Sends a PATCH request to update player related data. */
Expand Down

0 comments on commit aa6c0c1

Please sign in to comment.