utility: add charinfo
This commit is contained in:
		
							parent
							
								
									1f1e7531af
								
							
						
					
					
						commit
						e6de98c9ad
					
				
					 1 changed files with 26 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -60,7 +60,7 @@ const CUSTOM_EMOTE_REGEX = /<(?:\u200b|&)?(a)?:(\w+):(\d+)>/;
 | 
			
		|||
const fetch = require("node-fetch");
 | 
			
		||||
const sharp = require("sharp");
 | 
			
		||||
 | 
			
		||||
const {lookupUser} = require("../lib/utils.js");
 | 
			
		||||
const {hastebin, lookupUser} = require("../lib/utils.js");
 | 
			
		||||
const {getNamesFromString} = require("../lib/unicode.js");
 | 
			
		||||
 | 
			
		||||
const avatar = new Command("avatar");
 | 
			
		||||
| 
						 | 
				
			
			@ -576,3 +576,28 @@ jumbo.callback = async function (msg, line) {
 | 
			
		|||
  }
 | 
			
		||||
};
 | 
			
		||||
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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue