Skip to content

Commit

Permalink
Make so scripts don't download from patch version branches
Browse files Browse the repository at this point in the history
  • Loading branch information
Milkshiift committed Mar 20, 2024
1 parent 7af1cc0 commit ddab580
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/scriptLoader/scriptPreparer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ export async function installDefaultScripts() {
if (getConfig("autoUpdateDefaultScripts") === false) return;

try {
// GoofCord-Scripts repo has a branch for every version of GoofCord since 1.3.0
// GoofCord-Scripts repo has a branch for every minor and major version of GoofCord since 1.3.0
// That way scripts can use the newest features while remaining compatible with older versions
await download(`https://github.com/Milkshiift/GoofCord-Scripts/tree/${getVersion()}/patches`, scriptsFolder, scriptCategories.disabledScripts);
await download(`https://github.com/Milkshiift/GoofCord-Scripts/tree/${changePatchVersionToZero(getVersion())}/patches`, scriptsFolder, scriptCategories.disabledScripts);

console.log("[Script Loader] Successfully installed default scripts");
} catch (error: any) {
Expand All @@ -71,6 +71,12 @@ export async function installDefaultScripts() {
}
}

function changePatchVersionToZero(version: string): string {
const parts = version.split(".");
parts[2] = "0"; // Set patch version to 0
return parts.join(".");
}

function modifyScriptContent(content: string) {
content = "(async function(){" + content + "})();"; // Turning the script into an IIFE so variable names don't overlap
return content;
Expand Down

0 comments on commit ddab580

Please sign in to comment.