Emoji | Chat SDK (original) (raw)

Type-safe, cross-platform emoji that automatically convert to each platform's format.

The emoji helper provides cross-platform emoji that automatically convert to the correct format for each platform. On Slack, emoji render as :shortcode: format. On other platforms, they render as Unicode characters.

import { emoji } from "chat";

await thread.post(`${emoji.thumbs_up} Great job!`);
// Slack: ":+1: Great job!"
// Teams/GChat/Discord: "👍 Great job!"

Emoji also work in reactions:

await sent.addReaction(emoji.check);

bot.onReaction(["thumbs_up", "heart", "fire"], async (event) => {
  if (!event.added) return;
  await event.adapter.addReaction(event.threadId, event.messageId, emoji.raised_hands);
});
Name Emoji Name Emoji
emoji.thumbs_up 👍 emoji.thumbs_down 👎
emoji.heart ❤️ emoji.smile 😊
emoji.laugh 😂 emoji.thinking 🤔
emoji.eyes 👀 emoji.fire 🔥
emoji.check emoji.x
emoji.question emoji.party 🎉
emoji.rocket 🚀 emoji.star
emoji.wave 👋 emoji.clap 👏
emoji["100"] 💯 emoji.warning ⚠️
emoji.raised_hands 🙌 emoji.muscle 💪
emoji.ok_hand 👌 emoji.sad 😢
emoji.memo 📝 emoji.gear ⚙️
emoji.wrench 🔧 emoji.bug 🐛
emoji.calendar 📅 emoji.clock 🕐
emoji.sun ☀️ emoji.rainbow 🌈

For a one-off custom emoji, use emoji.custom("name").

For workspace-specific emoji with full type safety, use createEmoji():

import { createEmoji } from "chat";

const myEmoji = createEmoji({
  unicorn: { slack: "unicorn_face", gchat: "🦄" },
  company_logo: { slack: "company", gchat: "🏢" },
});

await thread.post(`${myEmoji.unicorn} Magic! ${myEmoji.company_logo}`);
// Slack: ":unicorn_face: Magic! :company:"
// GChat: "🦄 Magic! 🏢"

You can also extend the built-in emoji map with TypeScript module augmentation:

declare module "chat" {
  interface CustomEmojiMap {
    my_custom: EmojiFormats;
  }
}