From 95fe62051b8baa362906dda3e0e209fc2dbcd957 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 4 Dec 2023 19:26:36 +0000 Subject: [PATCH] chore: remove tag aliases with tag names *and* aliases both being options, we reach the limit for the discord API Signed-off-by: seth --- build.rs | 44 ++++++------------------------------- src/commands/general/tag.rs | 5 ++++- src/tags.rs | 1 - tags/always-offline.md | 1 - tags/binary-search.md | 1 - tags/curseforge.md | 1 - tags/fractureiser.md | 1 - tags/javaforgebugfix.md | 1 - tags/log.md | 1 - tags/macosarmjava.md | 1 - tags/migrate.md | 1 - tags/nightly.md | 1 - tags/optifine.md | 1 - tags/paths.md | 1 - tags/pluralkit.md | 1 - tags/update.md | 1 - tags/vcredist.md | 1 - tags/why.md | 6 ----- tags/whyjava8.md | 1 - 19 files changed, 11 insertions(+), 60 deletions(-) diff --git a/build.rs b/build.rs index 647d720..1426363 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,3 @@ -use std::collections::HashMap; use std::path::Path; use std::{env, fs}; @@ -22,11 +21,12 @@ fn main() { .into_iter() .map(|name| { let file_name = format!("{TAG_DIR}/{name}"); - let content = fs::read_to_string(&file_name).unwrap(); + let file_content = fs::read_to_string(&file_name).unwrap(); let matter = Matter::::new(); - let frontmatter: TagFrontmatter = matter - .parse(&content) + let parsed = matter.parse(&file_content); + let content = parsed.content; + let data = parsed .data .unwrap() .deserialize() @@ -40,31 +40,14 @@ fn main() { Tag { content, file_name: name, - frontmatter, + frontmatter: data, } }) .collect(); - let aliases: HashMap> = tags - .iter() - .filter_map(|t| { - t.frontmatter - .aliases - .clone() - .map(|aliases| (t.file_name.clone(), aliases)) - }) - .collect(); - let formatted_names: Vec = tags .iter() - .flat_map(|t| { - let mut res = Vec::from([t.file_name.replace(".md", "").replace('-', "_")]); - if let Some(tag_aliases) = aliases.get(&t.file_name) { - res.append(&mut tag_aliases.clone()) - } - - res - }) + .map(|t| t.file_name.replace(".md", "").replace('-', "_")) .collect(); let tag_choice = format!( @@ -91,20 +74,7 @@ fn main() { .iter() .map(|n| { let file_name = n.replace('_', "-") + ".md"; - - // assume this is an alias if we can't match the file name - let name = if tag_files.contains(&file_name) { - file_name - } else { - aliases - .iter() - .find(|a| a.1.contains(n)) - .unwrap() - .0 - .to_string() - }; - - format!("Self::{n} => \"{name}\",") + format!("Self::{n} => \"{file_name}\",") }) .collect::>() .join("\n") diff --git a/src/commands/general/tag.rs b/src/commands/general/tag.rs index d312bb5..ff1138c 100644 --- a/src/commands/general/tag.rs +++ b/src/commands/general/tag.rs @@ -11,7 +11,7 @@ include!(concat!(env!("OUT_DIR"), "/generated.rs")); static TAGS: Lazy> = Lazy::new(|| serde_json::from_str(env!("TAGS")).unwrap()); /// Send a tag -#[poise::command(slash_command)] +#[poise::command(slash_command, prefix_command)] pub async fn tag( ctx: Context<'_>, #[description = "the copypasta you want to send"] name: TagChoice, @@ -31,6 +31,9 @@ pub async fn tag( } m.embed(|e| { + e.title(&frontmatter.title); + e.description(&tag.content); + if let Some(color) = &frontmatter.color { let color = *consts::COLORS .get(color.as_str()) diff --git a/src/tags.rs b/src/tags.rs index a174fab..dacdd01 100644 --- a/src/tags.rs +++ b/src/tags.rs @@ -7,7 +7,6 @@ pub const TAG_DIR: &str = "tags"; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct TagFrontmatter { pub title: String, - pub aliases: Option>, pub color: Option, pub image: Option, pub fields: Option>, diff --git a/tags/always-offline.md b/tags/always-offline.md index a1a12d3..56b64ea 100644 --- a/tags/always-offline.md +++ b/tags/always-offline.md @@ -1,7 +1,6 @@ --- title: Prism Launcher is always offline? color: orange -aliases: ['reinstall'] --- If you recently updated Prism Launcher on Windows and you are now unable to do anything in Prism Launcher that would require an internet connection (i.e. logging in, downloading mods/modpacks and more), try uninstalling the launcher and then reinstalling it again. diff --git a/tags/binary-search.md b/tags/binary-search.md index 5472343..487a902 100644 --- a/tags/binary-search.md +++ b/tags/binary-search.md @@ -1,7 +1,6 @@ --- title: Binary Search - A method of finding problems with mods color: blue -aliases: ['thanosmethod'] --- 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/curseforge.md b/tags/curseforge.md index b2b8e78..cd67b98 100644 --- a/tags/curseforge.md +++ b/tags/curseforge.md @@ -1,7 +1,6 @@ --- title: What's wrong with CurseForge? color: orange -aliases: ['cf', 'curse', 'cursed', 'cursedfrog'] --- 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/fractureiser.md b/tags/fractureiser.md index 394f667..2a124d7 100644 --- a/tags/fractureiser.md +++ b/tags/fractureiser.md @@ -1,7 +1,6 @@ --- title: Information about Fractureiser color: orange -aliases: ['malware'] --- Starting June 6th, 2023 UTC, there have been reports of malware being distributed through websites such as Curseforge, Bukkit, and possibly others in the form of mods, plugins, and modpacks. According to both [Modrinth](https://twitter.com/modrinth/status/1666853947804463115) and [Curseforge](https://twitter.com/CurseForge/status/1666741580022128641), all infected files have been removed. These services should be safe to use now, however users should still take caution in downloading files, especially from less trustworthy services. diff --git a/tags/javaforgebugfix.md b/tags/javaforgebugfix.md index 9433d79..5b85315 100644 --- a/tags/javaforgebugfix.md +++ b/tags/javaforgebugfix.md @@ -1,7 +1,6 @@ --- title: Forge Bugfix color: yellow -aliases: ['javaforgebug', 'forgebug', 'forgejavabugfix', 'forgejavabug'] image: https://media.discordapp.net/attachments/1040383700845740072/1057840239751729172/Fix.png --- diff --git a/tags/log.md b/tags/log.md index 8299879..94a3cf6 100644 --- a/tags/log.md +++ b/tags/log.md @@ -1,7 +1,6 @@ --- title: Upload Logs color: orange -aliases: ['sendlog', 'logs'] image: https://cdn.discordapp.com/attachments/1031694870756204566/1156971972232740874/image.png --- diff --git a/tags/macosarmjava.md b/tags/macosarmjava.md index a2b5af3..cf3f406 100644 --- a/tags/macosarmjava.md +++ b/tags/macosarmjava.md @@ -1,7 +1,6 @@ --- title: Install arm64 Java on macOS color: yellow -aliases: ['armmacosjava'] --- On macOS arm64, also known as Apple Silicon (M1, M2, etc.), you will need to install the arm64 version of Java. We recommend using builds from Azul, the links for which can be found below: diff --git a/tags/migrate.md b/tags/migrate.md index 4045365..16886f3 100644 --- a/tags/migrate.md +++ b/tags/migrate.md @@ -1,7 +1,6 @@ --- title: Migrating from MultiMC color: orange -aliases: ['migr', 'mmc', 'multimc'] --- https://prismlauncher.org/wiki/getting-started/migrating-multimc/ diff --git a/tags/nightly.md b/tags/nightly.md index 0c83907..475feb6 100644 --- a/tags/nightly.md +++ b/tags/nightly.md @@ -1,7 +1,6 @@ --- title: Where can I download unstable builds of Prism Launcher? color: green -aliases: ['unstable'] --- You can download unstable builds [here](https://nightly.link/PrismLauncher/PrismLauncher/workflows/trigger_builds/develop). diff --git a/tags/optifine.md b/tags/optifine.md index 4d0271e..403e099 100644 --- a/tags/optifine.md +++ b/tags/optifine.md @@ -1,7 +1,6 @@ --- title: OptiFine color: green -aliases: ['of', 'optimize', 'opticrap', 'notfine'] --- OptiFine is known to cause problems when paired with other mods. diff --git a/tags/paths.md b/tags/paths.md index 693db03..6ae5961 100644 --- a/tags/paths.md +++ b/tags/paths.md @@ -1,7 +1,6 @@ --- title: Data directories color: blue -aliases: ['dirs', 'locate'] fields: - name: Portable (Windows / Linux) diff --git a/tags/pluralkit.md b/tags/pluralkit.md index b7f34d5..3334af9 100644 --- a/tags/pluralkit.md +++ b/tags/pluralkit.md @@ -1,7 +1,6 @@ --- title: Why PluralKit? color: blue -aliases: ['pk'] --- Plurality is the existence of multiple self-aware entities inside the same brain. diff --git a/tags/update.md b/tags/update.md index 3d022b9..ec17f2a 100644 --- a/tags/update.md +++ b/tags/update.md @@ -1,7 +1,6 @@ --- title: Does Prism Launcher auto-update? color: blue -aliases: ['updating', 'autoupdate'] --- Windows auto-updating is only supported on 8.0+. For Prism 7.2 or below, you will need to download the installer and run it again in order to update. On 8.0 or newer, click the 'Update' button. You will not lose your instances. diff --git a/tags/vcredist.md b/tags/vcredist.md index 23af9d6..c71ed9c 100644 --- a/tags/vcredist.md +++ b/tags/vcredist.md @@ -1,7 +1,6 @@ --- title: vcredist is required for Prism to run Windows color: pink -aliases: ['msvc'] --- 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 cc31d2e..77d5cf0 100644 --- a/tags/why.md +++ b/tags/why.md @@ -1,12 +1,6 @@ --- title: But why? color: purple -aliases: - - 'whywasprismlaunchermade' - - 'whywasprismmade' - - 'whywaspolymcmade' - - 'mmcdrama' - - 'devlauncher' --- https://prismlauncher.org/wiki/overview/faq/#why-did-our-community-choose-to-fork diff --git a/tags/whyjava8.md b/tags/whyjava8.md index d069e49..f4eac04 100644 --- a/tags/whyjava8.md +++ b/tags/whyjava8.md @@ -1,7 +1,6 @@ --- title: Why does Prism Launcher ask me to change Java version? color: orange -aliases: ['isjava8ancient', 'whyisprismforcingme'] --- 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.