From 8e279ae5cfdaa2d50e2a3d886d3bda41be3dd76e Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Sun, 14 May 2023 17:49:51 +0800 Subject: [PATCH] refactor(tags): pull embed options to top level and adopt embed images --- src/commands/tags.ts | 20 +++++++++----------- src/tags.ts | 34 +++++++++++++--------------------- tags/binary-search.md | 5 ++--- tags/build.md | 7 +++---- tags/curseforge.md | 7 +++---- tags/java.md | 6 +++--- tags/javaforgebugfix.md | 8 +++----- tags/legacyjavafixer.md | 6 ++---- tags/log.md | 9 ++++----- tags/migrate.md | 5 ++--- tags/optifine.md | 5 ++--- tags/paths.md | 28 ++++++++++++++-------------- tags/piracy.md | 5 ++--- tags/pluralkit.md | 7 +++---- tags/update.md | 8 ++++---- tags/vcredist.md | 5 ++--- tags/why.md | 5 ++--- tags/whyjava8.md | 10 +++++----- 18 files changed, 78 insertions(+), 102 deletions(-) diff --git a/src/commands/tags.ts b/src/commands/tags.ts index 840290d..870e452 100644 --- a/src/commands/tags.ts +++ b/src/commands/tags.ts @@ -24,17 +24,15 @@ export const tagsCommand = async ( return; } + const embed = new EmbedBuilder(); + embed.setTitle(tag.title ?? tag.name); + embed.setDescription(tag.content); + if (tag.color) embed.setColor(tag.color); + if (tag.image) embed.setImage(tag.image); + if (tag.fields) embed.setFields(tag.fields); + await i.reply({ - content: - (mention ? `<@${mention.id}> ` : '') + - (tag.text ? `**${tag.name}**\n\n` + tag.text : ''), - embeds: tag.embed - ? [ - new EmbedBuilder(tag.embed).setFooter({ - text: `Requested by ${i.user.tag}`, - iconURL: i.user.avatarURL() ?? undefined, - }), - ] - : [], + content: mention ? `<@${mention.id}> ` : undefined, + embeds: [embed], }); }; diff --git a/src/tags.ts b/src/tags.ts index e930ba4..3df1e2e 100644 --- a/src/tags.ts +++ b/src/tags.ts @@ -1,15 +1,18 @@ -import type { EmbedData } from 'discord.js'; - import matter from 'gray-matter'; import { readdir, readFile } from 'fs/promises'; import { join } from 'path'; import { COLORS } from './constants'; +import { type EmbedField } from 'discord.js'; + interface Tag { name: string; aliases?: string[]; - text?: string; - embed?: EmbedData; + title?: string; + color?: number; + content: string; + image?: string; + fields?: EmbedField[]; } const TAG_DIR = join(process.cwd(), 'tags'); @@ -22,23 +25,12 @@ export const getTags = async (): Promise => { const file = join(TAG_DIR, _file); const { data, content } = matter(await readFile(file)); - if (data.embed) { - tags.push({ - ...data, - name: _file.replace('.md', ''), - embed: { - ...data.embed, - description: content.trim(), - color: COLORS[data.embed.color], - }, - }); - } else { - tags.push({ - ...data, - name: _file.replace('.md', ''), - text: content.trim(), - }); - } + tags.push({ + ...data, + name: _file.replace('.md', ''), + content: content.trim(), + color: data.color ? COLORS[data.color] : undefined, + }); } return tags; diff --git a/tags/binary-search.md b/tags/binary-search.md index 14d3a09..5472343 100644 --- a/tags/binary-search.md +++ b/tags/binary-search.md @@ -1,8 +1,7 @@ --- +title: Binary Search - A method of finding problems with mods +color: blue aliases: ['thanosmethod'] -embed: - title: Binary Search - A method of finding problems with mods - color: blue --- The binary search is a way of finding a faulty thing amongst a lot of other things, without having to remove the things one-by-one. This is useful for finding a broken mod among hundreds of mods, without having to spend time testing the mods one-by-one. diff --git a/tags/build.md b/tags/build.md index 2ad8bef..10eb711 100644 --- a/tags/build.md +++ b/tags/build.md @@ -1,7 +1,6 @@ --- -embed: - title: Building Prism from scratch - color: blue +title: Building Prism from scratch +color: blue --- -https://prismlauncher.org/wiki/development/build-instructions/ \ No newline at end of file +https://prismlauncher.org/wiki/development/build-instructions/ diff --git a/tags/curseforge.md b/tags/curseforge.md index a5c2f53..b2b8e78 100644 --- a/tags/curseforge.md +++ b/tags/curseforge.md @@ -1,8 +1,7 @@ --- +title: What's wrong with CurseForge? +color: orange aliases: ['cf', 'curse', 'cursed', 'cursedfrog'] -embed: - title: What's wrong with CurseForge? - color: orange --- -CurseForge added a new option to block third party clients like Prism Launcher from accessing mod files, and they started to enforce this option lately. We can't allow you to download those mods directly from CurseForge because of this. However, Prism Launcher offers a workaround to enable the downloading of these mods, by allowing you to download these mods from your browser and automatically importing them into the instance. We highly encourage asking authors that opted out of client downloads to stop doing so. \ No newline at end of file +CurseForge added a new option to block third party clients like Prism Launcher from accessing mod files, and they started to enforce this option lately. We can't allow you to download those mods directly from CurseForge because of this. However, Prism Launcher offers a workaround to enable the downloading of these mods, by allowing you to download these mods from your browser and automatically importing them into the instance. We highly encourage asking authors that opted out of client downloads to stop doing so. diff --git a/tags/java.md b/tags/java.md index 26b7ea3..b60f1ae 100644 --- a/tags/java.md +++ b/tags/java.md @@ -1,6 +1,6 @@ --- -embed: - title: Java Instructions - color: orange +title: Java Instructions +color: orange --- + Currently, Prism Launcher does not bundle Java with itself. The instructions to setup and install Java can be found [here](https://prismlauncher.org/wiki/getting-started/installing-java/). diff --git a/tags/javaforgebugfix.md b/tags/javaforgebugfix.md index 681a69b..9433d79 100644 --- a/tags/javaforgebugfix.md +++ b/tags/javaforgebugfix.md @@ -1,13 +1,11 @@ --- +title: Forge Bugfix +color: yellow aliases: ['javaforgebug', 'forgebug', 'forgejavabugfix', 'forgejavabug'] -embed: - title: Forge Bugfix - color: yellow +image: https://media.discordapp.net/attachments/1040383700845740072/1057840239751729172/Fix.png --- 1. Click the instance that is broken, then select `Edit`. 2. Choose `Version` and then click `Forge`, then click the change version button. 3. You can then change the version, choose the latest, and click OK. 4. You are good to go! - -https://media.discordapp.net/attachments/1040383700845740072/1057840239751729172/Fix.png diff --git a/tags/legacyjavafixer.md b/tags/legacyjavafixer.md index d043635..0ccb6c4 100644 --- a/tags/legacyjavafixer.md +++ b/tags/legacyjavafixer.md @@ -1,8 +1,6 @@ --- -aliases: ['legacyjava', 'ljf'] -embed: - title: LegacyJavaFixer - color: yellow +title: LegacyJavaFixer +color: yellow --- MinecraftForge provides a coremod to fix some issues with older Forge versions on recent Java versions. You can download it [here](https://dist.creeper.host/FTB2/maven/net/minecraftforge/lex/legacyjavafixer/1.0/legacyjavafixer-1.0.jar). diff --git a/tags/log.md b/tags/log.md index d2f03d9..a17b25a 100644 --- a/tags/log.md +++ b/tags/log.md @@ -1,9 +1,8 @@ --- +title: Upload Logs +color: orange aliases: ['sendlog', 'logs', '🪵'] -embed: - title: Upload Logs - color: orange +image: https://media.discordapp.net/attachments/923671549758820434/1027408644289077268/unknown.png --- -Please send logs! The recommended site to upload your logs to is [mclo.gs](https://mclo.gs/). -https://media.discordapp.net/attachments/923671549758820434/1027408644289077268/unknown.png \ No newline at end of file +Please send logs! The recommended site to upload your logs to is [mclo.gs](https://mclo.gs/). diff --git a/tags/migrate.md b/tags/migrate.md index c404015..4045365 100644 --- a/tags/migrate.md +++ b/tags/migrate.md @@ -1,8 +1,7 @@ --- +title: Migrating from MultiMC +color: orange aliases: ['migr', 'mmc', 'multimc'] -embed: - title: Migrating from MultiMC - color: orange --- https://prismlauncher.org/wiki/getting-started/migrating-multimc/ diff --git a/tags/optifine.md b/tags/optifine.md index 74e2723..4d0271e 100644 --- a/tags/optifine.md +++ b/tags/optifine.md @@ -1,8 +1,7 @@ --- +title: OptiFine +color: green aliases: ['of', 'optimize', 'opticrap', 'notfine'] -embed: - title: OptiFine - color: green --- OptiFine is known to cause problems when paired with other mods. diff --git a/tags/paths.md b/tags/paths.md index ce47757..bc94366 100644 --- a/tags/paths.md +++ b/tags/paths.md @@ -1,19 +1,19 @@ --- +title: Data directories +color: blue aliases: ['dirs', 'locate'] -embed: - title: Data directories - color: blue - fields: - - name: Portable (Windows / Linux) - value: In the PrismLauncher folder - - name: Windows - value: '`%APPDATA%/PrismLauncher`' - - name: macOS - value: '`~/Library/Application Support/PrismLauncher`' - - name: Linux - value: '`~/.local/share/PrismLauncher`' - - name: Flatpak - value: '`~/.var/app/org.prismlauncher.PrismLauncher/data/PrismLauncher`' + +fields: + - name: Portable (Windows / Linux) + value: In the PrismLauncher folder + - name: Windows + value: '`%APPDATA%/PrismLauncher`' + - name: macOS + value: '`~/Library/Application Support/PrismLauncher`' + - name: Linux + value: '`~/.local/share/PrismLauncher`' + - name: Flatpak + value: '`~/.var/app/org.prismlauncher.PrismLauncher/data/PrismLauncher`' --- Where Prism Launcher stores your data (e.g. instances). diff --git a/tags/piracy.md b/tags/piracy.md index fb55393..234f290 100644 --- a/tags/piracy.md +++ b/tags/piracy.md @@ -1,7 +1,6 @@ --- -embed: - title: We don't tolerate piracy! - color: red +title: We don't tolerate piracy! +color: red --- Prism Launcher has always been legal, legitimate & appropriate. We don't and never will have features such as offline login without an official account. diff --git a/tags/pluralkit.md b/tags/pluralkit.md index c70328a..b7f34d5 100644 --- a/tags/pluralkit.md +++ b/tags/pluralkit.md @@ -1,8 +1,7 @@ --- +title: Why PluralKit? +color: blue aliases: ['pk'] -embed: - title: Why PluralKit? - color: blue --- Plurality is the existence of multiple self-aware entities inside the same brain. @@ -13,4 +12,4 @@ On Discord, some systems may use [PluralKit](https://pluralkit.me/) to make thei For more information about plurality, we recommend [More Than One](https://morethanone.info/) for a useful overview. -**Note: We do NOT tolerate the use of PluralKit for role playing.** \ No newline at end of file +**Note: We do NOT tolerate the use of PluralKit for role playing.** diff --git a/tags/update.md b/tags/update.md index 4401c57..28fd9de 100644 --- a/tags/update.md +++ b/tags/update.md @@ -1,11 +1,11 @@ --- +title: Does Prism Launcher auto-update? +color: blue aliases: ['updating', 'autoupdate'] -embed: - title: Does Prism Launcher auto-update? - color: blue --- + Windows auto-updating is WIP. For now, you will need to download the installer and run it again in order to update. You will not lose your instances. Prism Launcher auto-updates for macOS using the [Sparkle Framework](https://sparkle-project.org/). -For Linux, just use your package manager! \ No newline at end of file +For Linux, just use your package manager! diff --git a/tags/vcredist.md b/tags/vcredist.md index 8563734..23af9d6 100644 --- a/tags/vcredist.md +++ b/tags/vcredist.md @@ -1,8 +1,7 @@ --- +title: vcredist is required for Prism to run Windows +color: pink aliases: ['msvc'] -embed: - title: vcredist is required for Prism to run Windows - color: pink --- Like most apps on Windows, you have to install vcredist for Prism to run. Depending on what version of Prism you are using, you may need a different version. diff --git a/tags/why.md b/tags/why.md index 3278ee6..cc31d2e 100644 --- a/tags/why.md +++ b/tags/why.md @@ -1,13 +1,12 @@ --- +title: But why? +color: purple aliases: - 'whywasprismlaunchermade' - 'whywasprismmade' - 'whywaspolymcmade' - 'mmcdrama' - 'devlauncher' -embed: - title: But why? - color: purple --- https://prismlauncher.org/wiki/overview/faq/#why-did-our-community-choose-to-fork diff --git a/tags/whyjava8.md b/tags/whyjava8.md index 51784c1..d069e49 100644 --- a/tags/whyjava8.md +++ b/tags/whyjava8.md @@ -1,9 +1,9 @@ --- +title: Why does Prism Launcher ask me to change Java version? +color: orange aliases: ['isjava8ancient', 'whyisprismforcingme'] -embed: - title: Why does Prism Launcher ask me to change Java version? - color: orange --- -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, however, it's actually an LTS, meaning it's still getting updates. -If one of your mods is weird and requires newer Java, you can bypass this, by 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). \ No newline at end of file +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, however, it's actually an LTS, meaning it's still getting updates. + +If one of your mods is weird and requires newer Java, you can bypass this, by 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).