Skip to content

Commit

Permalink
fix(bot): fix startTime showing improperly on error
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah committed Oct 24, 2024
1 parent 6c9b3ca commit ac4849f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions apps/bot/src/modules/recorder/recording.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class Recording {

messageChannelID: string | null = null;
messageID: string | null = null;
startTime: [number, number] = [0, 0];
startTime: [number, number] | null = null;
startedAt: Date | null = null;
createdAt = new Date();
logs: string[] = [];
Expand Down Expand Up @@ -344,7 +344,7 @@ export default class Recording {
})
.catch((e) => this.recorder.logger.error(`Error writing end date to recording ${this.id}`, e));

const timestamp = process.hrtime(this.startTime);
const timestamp = process.hrtime(this.startTime!);
const time = timestamp[0] * 1000 + timestamp[1] / 1000000;
if (this.startedAt)
await onRecordingEnd(this.user.id, this.channel.guild.id, this.startedAt, time, this.autorecorded, !!this.webapp, false).catch(() => {});
Expand Down Expand Up @@ -678,7 +678,7 @@ export default class Recording {
if (!userID) return;

let recordingUser = this.users[userID];
const chunkTime = process.hrtime(this.startTime);
const chunkTime = process.hrtime(this.startTime!);
const time = chunkTime[0] * 48000 + ~~(chunkTime[1] / 20833.333);
if (!this.userPackets[userID]) this.userPackets[userID] = [];
if (!recordingUser) {
Expand Down Expand Up @@ -762,7 +762,7 @@ export default class Recording {
this.writer?.writeNoteHeader();
this.notePacketNo++;
}
const chunkTime = process.hrtime(this.startTime);
const chunkTime = process.hrtime(this.startTime!);
const chunkGranule = chunkTime[0] * 48000 + ~~(chunkTime[1] / 20833.333);
this.writer?.writeNote(chunkGranule, this.notePacketNo++, Buffer.from('NOTE' + note));
}
Expand Down

0 comments on commit ac4849f

Please sign in to comment.