From e0bbdd89bd33b1ed7361e316f137f3bfde34aff8 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 8 Oct 2022 21:11:14 +0200 Subject: [PATCH] fix lazyWebpack.construct, lint uwuify --- src/plugins/uwuify.ts | 75 +++++++++++++++++++++---------------------- src/utils/misc.tsx | 2 +- 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/src/plugins/uwuify.ts b/src/plugins/uwuify.ts index 710d0e856..8c8d790b9 100644 --- a/src/plugins/uwuify.ts +++ b/src/plugins/uwuify.ts @@ -1,7 +1,7 @@ import definePlugin from "../utils/types"; import { findOption, RequiredMessageOption } from "../api/Commands"; -//words have a chance of ending with these +// words have a chance of ending with these const endings = [ "owo", "UwU", @@ -25,7 +25,7 @@ const endings = [ "*sweats*", ]; -//replacement words +// replacement words const words = [ ["love", "wuv"], ["mr", "mistuh"], @@ -45,70 +45,69 @@ const words = [ ]; -//uwuify command +// uwuify command function uwuify(message: string): string { - let isowo = false; return message .split(" ") - .map(element => { - isowo = false; - let lowerCase = element.toLowerCase(); - //return if the word is too short - uwuifying short words makes them unreadable - if (element.length < 4) { - return element; + .map(w => { + let owofied = false; + let lowerCase = w.toLowerCase(); + // return if the word is too short - uwuifying short words makes them unreadable + if (w.length < 4) { + return w; } - //replacing the words based on the array on line 29 + // replacing the words based on the array on line 29 for (let [find, replace] of words) { - if (element.includes(find)) { - element = element.replace(find, replace); - isowo = true; + if (w.includes(find)) { + w = w.replace(find, replace); + owofied = true; } } - //these are the biggest word changes. if any of these are done we dont do the - //ones after the isowo check. to keep the words somewhat readable + // these are the biggest word changes. if any of these are done we dont do the + // ones after the isowo check. to keep the words somewhat readable if (lowerCase.includes("u") && !lowerCase.includes("uwu")) { - element = element.replace("u", "UwU"); - isowo = true; + w = w.replace("u", "UwU"); + owofied = true; } if (lowerCase.includes("o") && !lowerCase.includes("owo")) { - element = element.replace("o", "OwO"); - isowo = true; + w = w.replace("o", "OwO"); + owofied = true; } - if (lowerCase.endsWith("y") && element.length < 7) { - element = element + " " + "w" + element.slice(1); - isowo = true; + if (lowerCase.endsWith("y") && w.length < 7) { + w = w + " " + "w" + w.slice(1); + owofied = true; } - //returning if word has been already uwuified - to prevent over-uwuifying - if (isowo) { - return element; + // returning if word has been already uwuified - to prevent over-uwuifying + if (owofied) { + return w; } - //more tiny changes - to keep the words that passed through the latter changes uwuified + // more tiny changes - to keep the words that passed through the latter changes uwuified if (!lowerCase.endsWith("n")) { - element = element.replace("n", "ny"); + w = w.replace("n", "ny"); } - if (Math.floor(Math.random() * 2) == 1) { - element.replace("s", "sh"); + if (Math.floor(Math.random() * 2) === 1) { + w.replace("s", "sh"); } - if (Math.floor(Math.random() * 5) == 3 && !isowo) { - element = element[0] + "-" + element[0] + "-" + element; + if (Math.floor(Math.random() * 5) === 3 && !owofied) { + w = w[0] + "-" + w[0] + "-" + w; } - if (Math.floor(Math.random() * 5) == 3) { - element = - element + + if (Math.floor(Math.random() * 5) === 3) { + w = + w + " " + endings[Math.floor(Math.random() * endings.length)]; } - element = element.replace("r", "w").replace("l", "w"); - return element; + w = w.replaceAll("r", "w").replaceAll("l", "w"); + return w; }).join(" "); } -//actual command declaration +// actual command declaration export default definePlugin({ name: "UwUifier", description: "Simply uwuify commands", diff --git a/src/utils/misc.tsx b/src/utils/misc.tsx index 2ebf91c5a..f2228f8de 100644 --- a/src/utils/misc.tsx +++ b/src/utils/misc.tsx @@ -25,7 +25,7 @@ export function lazyWebpack(filter: FilterFn): T { has: (_, prop) => prop in getMod(), apply: (_, $this, args) => (getMod() as Function).apply($this, args), ownKeys: () => Reflect.ownKeys(getMod()), - construct: (_, args, newTarget) => new newTarget(...args), + construct: (_, args, newTarget) => Reflect.construct(getMod(), args, newTarget), deleteProperty: (_, prop) => delete getMod()[prop], defineProperty: (_, property, attributes) => !!Object.defineProperty(getMod(), property, attributes) }) as T;