Emoji

The emoji helper gives you named emoji that convert to each platform's format when posted. On Slack, they render as :shortcode: text. On other platforms, they render as Unicode characters.

Usage

lib/bot.ts
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:

lib/bot.ts
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);
});

Available emoji

NameEmojiNameEmoji
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").

Custom emoji

For workspace-specific emoji with typed names, use createEmoji():

lib/bot.ts
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:

lib/emoji.d.ts
declare module "chat" {
  interface CustomEmojiMap {
    my_custom: EmojiFormats;
  }
}

Read more