From 5a7d5f34678c6c707890766f902bb6f6a8a98d66 Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Tue, 26 Jul 2022 22:33:16 +0800 Subject: [PATCH] fix colors for embeds --- src/constants.ts | 3 ++- src/index.ts | 14 +++++++++++--- src/tags.json | 18 ++++++++++++------ 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index dad3351..e3fe6c0 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -21,9 +21,10 @@ export const ETA_MESSAGES = [ 'In PolyMC 2.0.0', ]; -export const COLORS = { +export const COLORS: { [color: string]: number } = { red: 0xef4444, green: 0x22c55e, blue: 0x60a5fa, yellow: 0xfde047, + orange: 0xfb923c, } as const; diff --git a/src/index.ts b/src/index.ts index 15622a2..fd5ff87 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,9 +36,17 @@ interface Tag { } export const getTags = async (): Promise => { - return JSON.parse( + const raw = JSON.parse( await readFile(join(__dirname, 'tags.json'), { encoding: 'utf8' }) - ); + ) as Tag[]; + + return raw.map((tag) => { + if (tag.embed?.color) { + tag.embed.color = BuildConfig.COLORS[tag.embed.color]; + } + + return tag; + }); }; const client = new Client({ @@ -123,7 +131,7 @@ async function parseMsgForCommands(e: Message) { } catch (err: unknown) { const em = new EmbedBuilder() .setTitle('Error') - .setColor('Red') + .setColor(BuildConfig.COLORS.red) // @ts-expect-error no why .setDescription(err['message'] as string); diff --git a/src/tags.json b/src/tags.json index 1b6c7a2..4729d96 100644 --- a/src/tags.json +++ b/src/tags.json @@ -22,6 +22,7 @@ "name": "optifine", "aliases": ["of", "optimize", "opticrap", "notfine"], "embed": { + "color": "green", "title": "OptiFine", "description": "OptiFine is known to cause problems when paired with other mods.\nPlease see [Installing OptiFine Alternatives](https://polymc.org/wiki/getting-started/install-of-alternatives/).\nIf you really want to use OptiFine, see [Installing OptiFine](https://polymc.org/wiki/getting-started/installing-optifine/)" } @@ -42,7 +43,7 @@ "embed": { "title": "Data directories", "description": "Where PolyMC stores your data (e.g. instances)", - + "color": "blue", "fields": [ { "name": "Portable (Windows / Linux)", @@ -85,7 +86,8 @@ "name": "whyjava8", "embed": { "title": "Why does PolyMC ask me to change java version?", - "description": "Minecraft versions before 1.17 required Java 8 and have issues with newer java, while newer versions require Java 17, so you need to change java version. Some people think Java 8 is very outdated, but it's actually an LTS, it's still getting updates. If one of your mods is weird and requires newer java, you can bypass this going to instance settings-Java and ticking 'Skip java compatibility checks', but be aware of potential issues, such as [random CMEs](https://bugs.mojang.com/browse/MC-149777)." + "description": "Minecraft versions before 1.17 required Java 8 and have issues with newer java, while newer versions require Java 17, so you need to change java version. Some people think Java 8 is very outdated, but it's actually an LTS, it's still getting updates. If one of your mods is weird and requires newer java, you can bypass this going to instance settings-Java and ticking 'Skip java compatibility checks', but be aware of potential issues, such as [random CMEs](https://bugs.mojang.com/browse/MC-149777).", + "color": "orange" }, "aliases": ["isjava8ancient", "whyispolyforcingme"] }, @@ -93,7 +95,8 @@ "name": "update", "embed": { "title": "Does PolyMC auto-update?", - "description": "PolyMC auto-updates for macOS using the Sparkle Framework.\n\nWindows auto-updating is WIP for now, you will need to download the installer and run it again. (You will not lose your instances.)\n\nFor Linux, just use your package manager!" + "description": "PolyMC auto-updates for macOS using the Sparkle Framework.\n\nWindows auto-updating is WIP for now, you will need to download the installer and run it again. (You will not lose your instances.)\n\nFor Linux, just use your package manager!", + "color": "blue" }, "aliases": ["updating", "autoupdate"] }, @@ -101,7 +104,8 @@ "name": "modupdater", "embed": { "title": "Mod updater", - "description": "Mod updating has been introduced in PolyMC 1.4.0! Upgrade if you haven't and you'll be able to use it." + "description": "Mod updating has been introduced in PolyMC 1.4.0! Upgrade if you haven't and you'll be able to use it.", + "color": "green" }, "aliases": ["mod-update", "modupdate"] }, @@ -109,7 +113,8 @@ "name": "curseforge", "embed": { "title": "What's wrong with CurseForge?", - "description": "CurseForge added a new option to block third party clients like PolyMC from accessing mod files, and they started to enforce this option lately. We can't allow you to download those mods directly from PolyMC, but PolyMC 1.3.1 and higher have a workaround to let modpacks work: letting you to download those opted out mods manually. We highly encourage asking authors that opted out to stop doing so." + "description": "CurseForge added a new option to block third party clients like PolyMC from accessing mod files, and they started to enforce this option lately. We can't allow you to download those mods directly from PolyMC, but PolyMC 1.3.1 and higher have a workaround to let modpacks work: letting you to download those opted out mods manually. We highly encourage asking authors that opted out to stop doing so.", + "color": "orange" }, "aliases": ["cf", "curse", "cursed", "cursedfrog"] }, @@ -117,7 +122,8 @@ "name": "piracy", "embed": { "title": "We don't tolerate piracy!", - "description": "PolyMC has always been legal, legitimate & appropriate. We don't and never will have features such as offline login without an official account." + "description": "PolyMC has always been legal, legitimate & appropriate. We don't and never will have features such as offline login without an official account.", + "color": "red" } } ]