rem-bot-industries / rem-v2

Well, this is the rewrite of rem, now even cleaner and hopefully with less bugs
Apache License 2.0
79 stars 43 forks source link

!w.large emoji command #93

Closed DasWolke closed 7 years ago

DasWolke commented 7 years ago

Suggested by @That guy#6367

ghost commented 7 years ago

Well, there's a way to detect emojis depending in the source I'll write it here, I hope it helps ^^

If it's a custom emoji You can use this regex to detect custom emojis from a server: \<\:.+\:\d+\> So it matches with results with <:emojiname:ID> If match is success, extract the ID using something like matchResult.replace(/[^0-9\s!?]+/g, '') so you'll get only the numbers Example: <:RemGasm:241616161861664778> => 241616161861664778 Once you got the numbers (the emoji ID) use it in a link that will redirect to the direct picture for the emoji https://cdn.discordapp.com/emojis/ID.png

If it's a built-in emoji This is pretty easy, you need the twemoji npm module which you can download here Generally this because Discord uses Twitter emojis and when those are typed, input logs as unicode but client converts it as PNG With this, you can use the function twemoji.convert.toCodePoint('unicodeEmojiOutputHere') and include it in the link from below https://raw.githubusercontent.com/twitter/twemoji/gh-pages/2/svg/twemoji.convert.toCodePoint('unicodeEmojiOutputHere').svg for example, if the emoji is :eyes:, discord will return unicode 👀 and link will be https://raw.githubusercontent.com/twitter/twemoji/gh-pages/2/svg/1f440.svg Now you'll get a SVG output. You'll need to use the request module to request the output. Then you need to do this

msg.channel.createMessage('', {
name: 'emoji.png',
file: svg2png(body, {width: '528', height: '528'}
})

I don't know how it's in your client but it's something like that