/* * Vencord, a Discord client mod * Copyright (c) 2025 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ import { definePluginSettings } from "@api/Settings"; import { OptionType } from "@utils/types"; export const settings = definePluginSettings({ addFreakyEnding: { type: OptionType.BOOLEAN, description: "Add 👅 or ❤️ at the end", default: true } }); export function rand(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } export async function getCuteAnimeBoys(sub: string) { const res = await fetch(`https://www.reddit.com/r/${sub}/top.json?limit=100&t=all`); const { children } = (await res.json()).data; const r = rand(0, children.length - 1); return children[r].data.url ?? ""; } export async function getCuteNeko(): Promise { const res = await fetch("https://nekos.best/api/v2/neko"); const url = (await res.json()).results[0].url as string | null; return url ?? ""; } export async function getCutePats(): Promise { const res = await fetch("https://api.waifu.pics/sfw/pat"); const url = (await res.json()).url as string | null; return url ?? ""; } export function mock(input: string): string { let output = ""; for (let i = 0; i < input.length; i++) { output += i % 2 ? input[i].toUpperCase() : input[i].toLowerCase(); } return output; } const charMap: Record = { q: "𝓺", w: "𝔀", e: "𝓮", r: "𝓻", t: "𝓽", y: "𝔂", u: "𝓾", i: "𝓲", o: "𝓸", p: "𝓹", a: "𝓪", s: "𝓼", d: "𝓭", f: "𝓯", g: "𝓰", h: "𝓱", j: "𝓳", k: "𝓴", l: "𝓵", z: "𝔃", x: "𝔁", c: "𝓬", v: "𝓿", b: "𝓫", n: "𝓷", m: "𝓶", Q: "𝓠", W: "𝓦", E: "𝓔", R: "𝓡", T: "𝓣", Y: "𝓨", U: "𝓤", I: "𝓘", O: "𝓞", P: "𝓟", A: "𝓐", S: "𝓢", D: "𝓓", F: "𝓕", G: "𝓖", H: "𝓗", J: "𝓙", K: "𝓚", L: "𝓛", Z: "𝓩", X: "𝓧", C: "𝓒", V: "𝓥", B: "𝓑", N: "𝓝", M: "𝓜", }; const mapCharacters = (text: string, map: Record) => text.split("").map(char => map[char] || char).join(""); export function makeFreaky(text: string) { text = mapCharacters(text.trim() || "freaky", charMap); if (settings.store.addFreakyEnding) text += Math.random() < 0.25 ? " 👅" : " ❤️"; return text; } const morseMap = { A: ".-", B: "-...", C: "-.-.", D: "-..", E: ".", F: "..-.", G: "--.", H: "....", I: "..", J: ".---", K: "-.-", L: ".-..", M: "--", N: "-.", O: "---", P: ".--.", Q: "--.-", R: ".-.", S: "...", T: "-", U: "..-", V: "...-", W: ".--", X: "-..-", Y: "-.--", Z: "--..", 0: "-----", 1: ".----", 2: "..---", 3: "...--", 4: "....-", 5: ".....", 6: "-....", 7: "--...", 8: "---..", 9: "----.", " ": "/" }; export const toMorse = (text: string) => { return text.toUpperCase().split("").map(char => morseMap[char] ?? "").join(" "); }; export const fromMorse = (text: string) => { const reversedMap = Object.fromEntries(Object.entries(morseMap).map(([k, v]) => [v, k])); const raw = text.split(" ").map(code => reversedMap[code] ?? "").join("").toLowerCase(); return raw.charAt(0).toUpperCase() + raw.slice(1); }; export const isMorse = (text: string) => /^[.\-/ ]+$/.test(text);