Discord slash command to get all emojis of a guild. Go to omg.ac/command and register a slash command as 'emojis' and you are ready to go.
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
// register the initial slash command response
await lib.discord.interactions['@1.0.1'].responses.create({
token: `${context.params.event.token}`,
response_type: 'DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE',
});
// now get all the emojis for the guild
let emojis = await lib.discord.guilds['@0.2.4'].emojis.list({
guild_id: context.params.event.guild_id,
});
// geeting only the emoji name and emoji id from the emojis array.
let list = emojis
.map((emoji) => {
let ifAnimated = emoji.animated;
if (ifAnimated) {
return ` | \`\` `;
} else {
return `<:${emoji.name}:${emoji.id}> | \`<:${emoji.name}:${emoji.id}>\` `;
}
})
.join('\n');
await lib.discord.interactions['@1.0.1'].followups.create({
token: `${context.params.event.token}`,
content: ` `,
embeds: [
{
type: `rich`,
title: ` ${emojis.length} Emojis `,
color: 0xff00f0,
description: list,
},
],
});