fix lazyWebpack.construct, lint uwuify

main
Vendicated 2 years ago
parent b101e643d5
commit e0bbdd89bd
No known key found for this signature in database
GPG Key ID: EC781ADFB93EFFA3

@ -1,7 +1,7 @@
import definePlugin from "../utils/types"; import definePlugin from "../utils/types";
import { findOption, RequiredMessageOption } from "../api/Commands"; import { findOption, RequiredMessageOption } from "../api/Commands";
//words have a chance of ending with these // words have a chance of ending with these
const endings = [ const endings = [
"owo", "owo",
"UwU", "UwU",
@ -25,7 +25,7 @@ const endings = [
"*sweats*", "*sweats*",
]; ];
//replacement words // replacement words
const words = [ const words = [
["love", "wuv"], ["love", "wuv"],
["mr", "mistuh"], ["mr", "mistuh"],
@ -45,70 +45,69 @@ const words = [
]; ];
//uwuify command // uwuify command
function uwuify(message: string): string { function uwuify(message: string): string {
let isowo = false;
return message return message
.split(" ") .split(" ")
.map(element => { .map(w => {
isowo = false; let owofied = false;
let lowerCase = element.toLowerCase(); let lowerCase = w.toLowerCase();
//return if the word is too short - uwuifying short words makes them unreadable // return if the word is too short - uwuifying short words makes them unreadable
if (element.length < 4) { if (w.length < 4) {
return element; 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) { for (let [find, replace] of words) {
if (element.includes(find)) { if (w.includes(find)) {
element = element.replace(find, replace); w = w.replace(find, replace);
isowo = true; owofied = true;
} }
} }
//these are the biggest word changes. if any of these are done we dont do the // 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 // ones after the isowo check. to keep the words somewhat readable
if (lowerCase.includes("u") && !lowerCase.includes("uwu")) { if (lowerCase.includes("u") && !lowerCase.includes("uwu")) {
element = element.replace("u", "UwU"); w = w.replace("u", "UwU");
isowo = true; owofied = true;
} }
if (lowerCase.includes("o") && !lowerCase.includes("owo")) { if (lowerCase.includes("o") && !lowerCase.includes("owo")) {
element = element.replace("o", "OwO"); w = w.replace("o", "OwO");
isowo = true; owofied = true;
} }
if (lowerCase.endsWith("y") && element.length < 7) { if (lowerCase.endsWith("y") && w.length < 7) {
element = element + " " + "w" + element.slice(1); w = w + " " + "w" + w.slice(1);
isowo = true; owofied = true;
} }
//returning if word has been already uwuified - to prevent over-uwuifying // returning if word has been already uwuified - to prevent over-uwuifying
if (isowo) { if (owofied) {
return element; 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")) { if (!lowerCase.endsWith("n")) {
element = element.replace("n", "ny"); w = w.replace("n", "ny");
} }
if (Math.floor(Math.random() * 2) == 1) { if (Math.floor(Math.random() * 2) === 1) {
element.replace("s", "sh"); w.replace("s", "sh");
} }
if (Math.floor(Math.random() * 5) == 3 && !isowo) { if (Math.floor(Math.random() * 5) === 3 && !owofied) {
element = element[0] + "-" + element[0] + "-" + element; w = w[0] + "-" + w[0] + "-" + w;
} }
if (Math.floor(Math.random() * 5) == 3) { if (Math.floor(Math.random() * 5) === 3) {
element = w =
element + w +
" " + " " +
endings[Math.floor(Math.random() * endings.length)]; endings[Math.floor(Math.random() * endings.length)];
} }
element = element.replace("r", "w").replace("l", "w"); w = w.replaceAll("r", "w").replaceAll("l", "w");
return element; return w;
}).join(" "); }).join(" ");
} }
//actual command declaration // actual command declaration
export default definePlugin({ export default definePlugin({
name: "UwUifier", name: "UwUifier",
description: "Simply uwuify commands", description: "Simply uwuify commands",

@ -25,7 +25,7 @@ export function lazyWebpack<T = any>(filter: FilterFn): T {
has: (_, prop) => prop in getMod(), has: (_, prop) => prop in getMod(),
apply: (_, $this, args) => (getMod() as Function).apply($this, args), apply: (_, $this, args) => (getMod() as Function).apply($this, args),
ownKeys: () => Reflect.ownKeys(getMod()), ownKeys: () => Reflect.ownKeys(getMod()),
construct: (_, args, newTarget) => new newTarget(...args), construct: (_, args, newTarget) => Reflect.construct(getMod(), args, newTarget),
deleteProperty: (_, prop) => delete getMod()[prop], deleteProperty: (_, prop) => delete getMod()[prop],
defineProperty: (_, property, attributes) => !!Object.defineProperty(getMod(), property, attributes) defineProperty: (_, property, attributes) => !!Object.defineProperty(getMod(), property, attributes)
}) as T; }) as T;

Loading…
Cancel
Save