import * as z from "zod" import { defineAction } from "../../../automation/actions" import { getSlackApi } from "../lib/api" import { SLACK_EMOJI_READ_SCOPE } from "../lib/scopes" const EMOJI_LIST_RESPONSE_SCHEMA = z.looseObject({ emoji: z.record(z.string(), z.string()), ok: z.literal(true), }) /** Lists custom emoji names and their image URLs or aliases. */ export const listSlackCustomEmoji = defineAction("List Slack custom emoji") .describe("Lists custom Slack emoji names and their image URLs or aliases.") .account("slack", SLACK_EMOJI_READ_SCOPE) .output(z.record(z.string(), z.string())) .retry({ replaySafety: "safe" }) .handler( async ({ account }) => ( await getSlackApi(account.secret).call("emoji.list", { responseSchema: EMOJI_LIST_RESPONSE_SCHEMA, }) ).emoji, )