2021-04-05 12:21:27 +00:00
|
|
|
|
import {Command, NamedCommand} from "../../core";
|
2021-03-31 01:40:29 +00:00
|
|
|
|
|
|
|
|
|
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!";
|
|
|
|
|
|
2021-04-05 12:21:27 +00:00
|
|
|
|
export default new NamedCommand({
|
2021-03-31 01:40:29 +00:00
|
|
|
|
description: "Transforms your text into vietnamese.",
|
|
|
|
|
usage: "thonk ([text])",
|
2021-04-05 12:21:27 +00:00
|
|
|
|
async run({message, channel, guild, author, member, client, args}) {
|
|
|
|
|
if (args.length > 0) phrase = args.join(" ");
|
2021-04-08 11:37:49 +00:00
|
|
|
|
const msg = await channel.send(transform(phrase));
|
|
|
|
|
msg.createReactionCollector(
|
|
|
|
|
(reaction, user) => {
|
|
|
|
|
if (user.id === author.id && reaction.emoji.name === "❌") msg.delete();
|
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
{time: 60000}
|
|
|
|
|
);
|
2021-03-31 01:40:29 +00:00
|
|
|
|
}
|
|
|
|
|
});
|