import define from "../define.js"; import { ApiError } from "../error.js"; import { populateEmojiOrUserEmoji } from "../../../misc/populate-emojis.js"; export const meta = { tags: [ "meta" ], requireCredential: false, allowGet: true, cacheSec: 3600, res: { type: "object", optional: false, nullable: false, properties: { name: { type: "string", optional: false, nullable: false }, url: { type: "string", optional: false, nullable: false }, glyph: { type: "boolean", optional: false, nullable: false }, glyphUrl: { type: "string", optional: false, nullable: true }, width: { type: "number", optional: false, nullable: true }, height: { type: "number", optional: false, nullable: true } } }, errors: { noSuchEmoji: { message: "No such emoji.", code: "NO_SUCH_EMOJI", id: "fc46b5a4-6b92-49e7-9e24-8d9a974f31a4" } } }; export const paramDef = { type: "object", properties: { name: { type: "string" } }, required: [ "name" ] }; export default define(meta, paramDef, async (ps, me)=>{ const name = /^([:;]).+\1$/.test(ps.name) ? ps.name.slice(1, -1) : ps.name; const emoji = await populateEmojiOrUserEmoji(name, null); if (!emoji) throw new ApiError(meta.errors.noSuchEmoji); return { name: emoji.name, url: emoji.url, glyph: emoji.glyph, glyphUrl: emoji.glyphUrl, width: emoji.width, height: emoji.height }; });