utility: add charinfo

This commit is contained in:
Cynthia Foxwell 2022-03-29 11:38:02 -06:00
parent 1f1e7531af
commit e6de98c9ad

View file

@ -60,7 +60,7 @@ const CUSTOM_EMOTE_REGEX = /<(?:\u200b|&)?(a)?:(\w+):(\d+)>/;
const fetch = require("node-fetch"); const fetch = require("node-fetch");
const sharp = require("sharp"); const sharp = require("sharp");
const {lookupUser} = require("../lib/utils.js"); const {hastebin, lookupUser} = require("../lib/utils.js");
const {getNamesFromString} = require("../lib/unicode.js"); const {getNamesFromString} = require("../lib/unicode.js");
const avatar = new Command("avatar"); const avatar = new Command("avatar");
@ -576,3 +576,28 @@ jumbo.callback = async function (msg, line) {
} }
}; };
hf.registerCommand(jumbo); hf.registerCommand(jumbo);
const charinfo = new Command("charinfo");
charinfo.category = CATEGORY;
charinfo.description = "Get information about a set of characters.";
charinfo.usage = "[characters]";
charinfo.addAlias("char");
charinfo.callback = async function (msg, line) {
const names = getNamesFromString(line);
const chars = [...line];
const lines = names
.map(
([code, name], index) =>
`\`\\u${code}\`: ${name} - ${chars[index]} - <http://www.fileformat.info/info/unicode/char/${code}>`
)
.join("\n");
if (lines.length > 2000) {
return `Output too long: ${hf.config.haste_provider}/${await hastebin(
lines
)}`;
} else {
return lines;
}
};
hf.registerCommand(charinfo);