TravBot-v3/src/commands/fun/thonk.ts

60 lines
1.9 KiB
TypeScript
Raw Normal View History

2021-04-10 19:08:36 +00:00
import {Command, NamedCommand, RestCommand} from "../../core";
const letters: {[letter: string]: string[]} = {
a: "aáàảãạâấầẩẫậăắằẳẵặ".split(""),
e: "eéèẻẽẹêếềểễệ".split(""),
i: "iíìỉĩị".split(""),
o: "oóòỏõọôốồổỗộơớờởỡợ".split(""),
u: "uúùủũụưứừửữự".split(""),
y: "yýỳỷỹỵ".split(""),
d: "dđ".split("")
};
function transform(str: string) {
let out = "";
for (const c of str) {
const token = c.toLowerCase();
const isUpperCase = token !== c;
if (token in letters) {
const set = letters[token];
const add = set[Math.floor(Math.random() * set.length)];
out += isUpperCase ? add.toUpperCase() : add;
} else {
out += c;
}
}
return out;
}
let phrase = "I have no currently set phrase!";
export default new NamedCommand({
description: "Transforms your text into .",
usage: "thonk ([text])",
2021-04-10 13:34:55 +00:00
async run({send, message, channel, guild, author, member, client, args}) {
const msg = await send(transform(phrase));
2021-04-08 11:37:49 +00:00
msg.createReactionCollector(
(reaction, user) => {
if (user.id === author.id && reaction.emoji.name === "❌") msg.delete();
return false;
},
{time: 60000}
);
2021-04-10 19:08:36 +00:00
},
any: new RestCommand({
async run({send, message, channel, guild, author, member, client, args, combined}) {
const msg = await send(transform(combined));
msg.createReactionCollector(
(reaction, user) => {
if (user.id === author.id && reaction.emoji.name === "❌") msg.delete();
return false;
},
{time: 60000}
);
}
})
});