import { emoji, createEmoji } from "chat";
import type { EmojiFormats } from "chat";
// Extend with custom emoji
declare module "chat" {
interface CustomEmojiMap {
priority_high: EmojiFormats;
priority_low: EmojiFormats;
}
}
const customEmoji = createEmoji({
priority_high: { slack: "red_circle", gchat: "🔴" },
priority_low: { slack: "green_circle", gchat: "🟢" }
});
// Message with emoji
chat.onNewMention(async (thread, message) => {
await thread.post(
`${emoji.wave} Hello! Processing your request ${emoji.gear}`
);
// Do work...
await thread.post(
`${emoji.check} Done! ${customEmoji.priority_low}`
);
});
// Reaction handling
chat.onReaction([emoji.thumbs_up, emoji.thumbs_down], async (event) => {
if (event.emoji === emoji.thumbs_up) {
await event.thread.post(
`Thanks for the positive feedback, ${event.user.userName}!`
);
} else {
await event.thread.post(
`We'll work on improving. ${emoji.pray}`
);
}
});
// Add reactions to messages
const sent = await thread.post("Ready to deploy?");
await sent.addReaction(emoji.rocket);
await sent.addReaction(emoji.check);
await sent.addReaction(customEmoji.priority_high);