Code for a prefix command like `!large π` that sends a message to the channel with a large image of the emoji. This only works for custom emojis.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const prefixCommand = '!large';
const content = context.params.event.content;
const contentParts = content.split(' ');
// Verify the prefix command and get the emoji
if (contentParts.length !== 2) return;
if (contentParts[0] !== prefixCommand) return;
const emoji = contentParts[1];
// Is it a custom emoji?
const emojiParts = emoji.split(':');
const isCustomEmoji = emojiParts.length === 3;
if (isCustomEmoji) {
// Get the custom emoji ID
const emojiId = emojiParts[2].slice(0, -1);
// Send the embed!
await lib.discord.channels['@0.1.2'].messages.create({
channel_id: context.params.event.channel_id,
content: ``,
embed: {
title: 'Large emoji viewer',
image: {
url: `https://cdn.discordapp.com/emojis/${emojiId}.png`,
},
},
});
} else {
await lib.discord.channels['@0.1.2'].messages.create({
channel_id: context.params.event.channel_id,
content: `Standard emojis like ${emoji} aren't supported. Please use a custom one.`,
});
}