UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

24 lines (22 loc) 741 B
import { Identifiers } from "../errors/Identifiers.mjs"; import { parseEmoji } from "discord.js"; import { Result } from "@sapphire/result"; import { EmojiRegex, createTwemojiRegex } from "@sapphire/discord-utilities"; //#region src/lib/resolvers/emoji.ts const TwemojiRegex = createTwemojiRegex(); function resolveEmoji(parameter) { const twemoji = TwemojiRegex.exec(parameter)?.[0] ?? null; TwemojiRegex.lastIndex = 0; if (twemoji) return Result.ok({ name: twemoji, id: null }); if (EmojiRegex.test(parameter)) { const resolved = parseEmoji(parameter); if (resolved) return Result.ok(resolved); } return Result.err(Identifiers.ArgumentEmojiError); } //#endregion export { resolveEmoji }; //# sourceMappingURL=emoji.mjs.map