This snippet will fetch information about an emoji! Note that this is only feasible for standard and common emojis. To use the command, you shall type the prefix followed by space and the emoji. (eg. !emoji-info π)
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const {EmojiAPI} = require('emoji-api');
const emoji = new EmojiAPI();
const userEmoji = context.params.event.content.split(' ').slice(1)[0];
try {
let info = await emoji.get(userEmoji).then(async function (emoji) {
return emoji;
});
let images =
info.images?.map((img) => {
return `[${img.vendor}](${img.url})`;
}) || null;
let imageCollection = ``;
if (images) {
imageCollection =
`**Emoji from different platforms:**\n ` + images.join('\n');
}
await lib.discord.channels['@0.3.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: '',
tts: false,
message_reference: {
message_id: `${context.params.event.id}`,
},
embeds: [
{
type: 'rich',
title: `${info.name} ${userEmoji}`,
description: [`${info.description}`, `${imageCollection}`].join('\n\n'),
color: 0xd400ff,
thumbnail: {
url: `${info.images[0]?.url || info.images[1]?.url}`,
height: 0,
width: 0,
},
footer: {
text: `Developed by fidilen#1432`,
},
},
],
});
} catch (e) {
return lib.discord.channels['@0.3.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `:x: ${e.message}`,
message_reference: {
message_id: `${context.params.event.id}`,
},
});
}