import type { Message , TextChannel } from "eris" ; import { defaultEmojiRegex , emojiIDArgRegex } from "../../utils/constants" ; import { Command } from "../../classes/Command" ; export class EmojiCommand extends Command { aliases = [ "emote" , "enlarge" ] ; args = "<emoji:string>" ; description = "Enlarges an emoji." ; async run ( msg , _pargs , args ) { const emoji = args . join ( "" ) . match ( emojiIDArgRegex ) ; const animated = /<[a]:/g . test ( args . join ( "" ) ) ; if ( ! emoji && ! defaultEmojiRegex . test ( args [ 0 ] ) ) { return msg . createEmbed ( msg . string ( "global.ERROR" ) , msg . string ( "utility.EMOJI_NOEMOJI" ) , "error" ) ; } function toEmoji ( string ) { const characters = [ ] ; let charCode = 0 ; let sgFix = 0 ; for ( let i = 0 ; i < string . length ; i ++ ) { charCode = string . charCodeAt ( i ) ; if ( sgFix ) { characters . push ( ( 0x10000 + ( ( sgFix - 0xd800 ) << 10 ) + ( charCode - 0xdc00 ) ) . toString ( 16 ) ) ; sgFix = 0 ; } else if ( charCode >= 0xd800 && charCode <= 0xdbff ) { sgFix = charCode ; } else { characters . push ( charCode . toString ( 16 ) ) ; } } return characters . join ( "-" ) ; } if ( ! emoji ) { if ( defaultEmojiRegex . test ( args [ 0 ] ) ) { return msg . channel . createMessage ( { embed : { title : `${ args [ 0 ] }` , color : msg . convertHex ( "general" ) , image : { url : `https://twemoji.maxcdn.com/v/13.0.0/72x72/${ toEmoji ( args [ 0 ] ) }.png` , } , footer : { text : msg . string ( "global.RAN_BY" , { author : msg . tagUser ( msg . author ) } ) , icon_url : msg . author . dynamicAvatarURL ( ) , } , } , } ) ; } } msg . channel . createMessage ( { embed : { title : `${ args [ 0 ] }` , color : msg . convertHex ( "general" ) , image : { url : `https://cdn.discordapp.com/emojis/${ emoji }.${ animated ? "gif" : "png" }` , } , footer : { text : msg . string ( "global.RAN_BY" , { author : msg . tagUser ( msg . author ) } ) , icon_url : msg . author . dynamicAvatarURL ( ) , } , } , } ) ; } }