Search emoji or get a random emoji from emoji.gg website. Just use the !emoji command and give the emoji name if you want to search and if you do not give name then it will send a random emoji.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const axios = require('axios');
const stringSimilarity = require('string-similarity');
if (context.params.event.content.startsWith('!emoji')) {
const args = context.params.event.content.split(' ').slice(1);
const emojiJson = await axios('https://emoji.gg/api/').then(
(res) => res.data
);
let emoji = args[0]
? emojiJson[
stringSimilarity.findBestMatch(
args.join(' '),
emojiJson.map((x) => x.title)
)?.bestMatchIndex || Math.floor(Math.random() * emojiJson.length)
]
: emojiJson[Math.floor(Math.random() * emojiJson.length)];
return lib.discord.channels['@0.2.0'].messages.create({
channel_id: context.params.event.channel_id,
content: ``,
embed: {
titel: emoji.title,
color: 0xffff,
description: emoji.description,
image: {url: emoji.image},
footer: {text: `${emoji.submitted_by} | submitter`},
},
});
}