From 321d9780ad11bf9c00b747695429bda295d543e2 Mon Sep 17 00:00:00 2001 From: Tarrgon <61888458+Tarrgon@users.noreply.github.com> Date: Sun, 28 Sep 2025 15:47:21 -0400 Subject: [PATCH] Add comments explaining these methods These methods aren't accurate to their names as they manipulate the data returned to better suit the purposes of the bot. --- src/utils/file-utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/file-utils.ts b/src/utils/file-utils.ts index 64da845..d52365f 100644 --- a/src/utils/file-utils.ts +++ b/src/utils/file-utils.ts @@ -14,6 +14,8 @@ export function calculateMD5(data: Buffer): string { return crypto.createHash('md5').update(data).digest('hex'); } +// Downloads a file from discord's CDN and reverts the changes they do to the file. +// Returns both the corrected version at index 0, and the original version from discord at index 1. export async function downloadFile(url: string): Promise { try { const res = await fetch(url); @@ -51,6 +53,8 @@ export async function downloadFile(url: string): Promise { } } +// This method is used with discord CDN URLs. +// Discord does slight modifications to the data, which will change the MD5, this method reverts those changes. export async function calculateMD5FromURL(url: string): Promise<{ correctedFileMD5: string, originalFileMD5: string } | null> { try { const files = await downloadFile(url);