Skip to content

Commit

Permalink
Additional session logging (#2236)
Browse files Browse the repository at this point in the history
* Additional session logging

* Add vc valid check
  • Loading branch information
Brainicism authored Oct 8, 2024
1 parent 323cc57 commit 394ed45
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/structures/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ export default abstract class Session {
logger.info(
`${getDebugLogHeader(
messageContext,
)} | ${this.sessionName()} starting`,
)} | ${this.sessionName()} initializing session`,
);
} else {
logger.info(
`${getDebugLogHeader(messageContext)} | Round starting`,
);
}

Expand Down Expand Up @@ -357,6 +361,7 @@ export default abstract class Session {
isError: boolean,
_messageContext?: MessageContext,
): Promise<void> {
logger.info(`gid: ${this.guildID} | Round ending`);
if (this.round === null) {
return;
}
Expand Down Expand Up @@ -1329,18 +1334,26 @@ export default abstract class Session {
);
}

// check if voice connection is still valid
// channel ID is null'd if disconnected
if (this.connection.channelID) {
return;
}

if (!this.connection.piper.encoding) {
return;
}

logger.warn("Connection is unexpectedly in encoding state.");
logger.warn(
`gid: ${this.guildID} | Connection is unexpectedly in encoding state.`,
);
await delay(1000);

// if still encoding, force stop
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (this.connection.piper.encoding) {
logger.warn(
"Connection is still in encoding state after timeout, force stop.",
`gid: ${this.guildID} | Connection is still in encoding state after timeout, force stop.`,
);
this.connection.stopPlaying();
}
Expand Down

0 comments on commit 394ed45

Please sign in to comment.