mirror of
https://github.com/System-End/Vencord.git
synced 2026-04-19 23:22:48 +00:00
VoiceMessages: fix 'Failed to finish recording' error
This commit is contained in:
parent
1047f5b24e
commit
ca5c58bfa8
1 changed files with 3 additions and 3 deletions
|
|
@ -5,18 +5,18 @@
|
|||
*/
|
||||
|
||||
import { app } from "electron";
|
||||
import { readFile } from "fs/promises";
|
||||
import { readFile, rm } from "fs/promises";
|
||||
import { basename, normalize } from "path";
|
||||
|
||||
export async function readRecording(_, filePath: string) {
|
||||
filePath = normalize(filePath);
|
||||
const filename = basename(filePath);
|
||||
const discordBaseDirWithTrailingSlash = normalize(app.getPath("userData") + "/");
|
||||
console.log(filename, discordBaseDirWithTrailingSlash, filePath);
|
||||
if (filename !== "recording.ogg" || !filePath.startsWith(discordBaseDirWithTrailingSlash)) return null;
|
||||
if (!/^\d*recording\.ogg$/.test(filename) || !filePath.startsWith(discordBaseDirWithTrailingSlash)) return null;
|
||||
|
||||
try {
|
||||
const buf = await readFile(filePath);
|
||||
rm(filePath).catch(() => { });
|
||||
return new Uint8Array(buf.buffer);
|
||||
} catch {
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue