fix colors for embeds

This commit is contained in:
Ryan Cao 2022-07-26 22:33:16 +08:00
parent 7c0b91e1be
commit 5a7d5f3467
No known key found for this signature in database
GPG key ID: 528A2C1B6656B97F
3 changed files with 25 additions and 10 deletions

View file

@ -21,9 +21,10 @@ export const ETA_MESSAGES = [
'In PolyMC 2.0.0', 'In PolyMC 2.0.0',
]; ];
export const COLORS = { export const COLORS: { [color: string]: number } = {
red: 0xef4444, red: 0xef4444,
green: 0x22c55e, green: 0x22c55e,
blue: 0x60a5fa, blue: 0x60a5fa,
yellow: 0xfde047, yellow: 0xfde047,
orange: 0xfb923c,
} as const; } as const;

View file

@ -36,9 +36,17 @@ interface Tag {
} }
export const getTags = async (): Promise<Tag[]> => { export const getTags = async (): Promise<Tag[]> => {
return JSON.parse( const raw = JSON.parse(
await readFile(join(__dirname, 'tags.json'), { encoding: 'utf8' }) 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({ const client = new Client({
@ -123,7 +131,7 @@ async function parseMsgForCommands(e: Message) {
} catch (err: unknown) { } catch (err: unknown) {
const em = new EmbedBuilder() const em = new EmbedBuilder()
.setTitle('Error') .setTitle('Error')
.setColor('Red') .setColor(BuildConfig.COLORS.red)
// @ts-expect-error no why // @ts-expect-error no why
.setDescription(err['message'] as string); .setDescription(err['message'] as string);

View file

@ -22,6 +22,7 @@
"name": "optifine", "name": "optifine",
"aliases": ["of", "optimize", "opticrap", "notfine"], "aliases": ["of", "optimize", "opticrap", "notfine"],
"embed": { "embed": {
"color": "green",
"title": "OptiFine", "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/)" "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": { "embed": {
"title": "Data directories", "title": "Data directories",
"description": "Where PolyMC stores your data (e.g. instances)", "description": "Where PolyMC stores your data (e.g. instances)",
"color": "blue",
"fields": [ "fields": [
{ {
"name": "Portable (Windows / Linux)", "name": "Portable (Windows / Linux)",
@ -85,7 +86,8 @@
"name": "whyjava8", "name": "whyjava8",
"embed": { "embed": {
"title": "Why does PolyMC ask me to change java version?", "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"] "aliases": ["isjava8ancient", "whyispolyforcingme"]
}, },
@ -93,7 +95,8 @@
"name": "update", "name": "update",
"embed": { "embed": {
"title": "Does PolyMC auto-update?", "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"] "aliases": ["updating", "autoupdate"]
}, },
@ -101,7 +104,8 @@
"name": "modupdater", "name": "modupdater",
"embed": { "embed": {
"title": "Mod updater", "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"] "aliases": ["mod-update", "modupdate"]
}, },
@ -109,7 +113,8 @@
"name": "curseforge", "name": "curseforge",
"embed": { "embed": {
"title": "What's wrong with CurseForge?", "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"] "aliases": ["cf", "curse", "cursed", "cursedfrog"]
}, },
@ -117,7 +122,8 @@
"name": "piracy", "name": "piracy",
"embed": { "embed": {
"title": "We don't tolerate piracy!", "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"
} }
} }
] ]