UNPKG

@grammyjs/emoji

Version:

Use emoji names instead of Unicode strings. Copy-pasting emoji sucks.

34 lines (33 loc) 1.42 kB
import { Context, NextFunction } from "./deps.node.js"; import emojis from "./emojidata.js"; type EmojiList = typeof emojis; type EmojiName = keyof EmojiList | (string & Record<never, never>); export type EmojiFlavor<C extends Context = Context> = C & { /** * You can use this method to parse a string with emojis. * * Keep in mind that you need to use this method with a template string. * * Examples: * ```ts * const text = ctx.emoji`LOL ${'face_with_tears_of_joy'}!`; // => "LOL 😂!" * await ctx.reply(ctx.emoji`This is an example! ${'smiling_face_with_halo'}`); // => "This is an example! 😇" * ``` */ emoji: (name: TemplateStringsArray, ...emojis: EmojiName[]) => string; /** * You can use this method to directly reply to a message * with emojis parsing. * * Keep in mind that you need to use this method with a template string. * * Examples: * ```ts * await ctx.replyWithEmoji`This is an example! ${'smiling_face_with_halo'}`; // => "This is an example! 😇" * ``` */ replyWithEmoji: (string: TemplateStringsArray, ...emojis: EmojiName[]) => ReturnType<C["reply"]>; }; export declare function emoji(name: EmojiName): string; export declare function emojiParser<C extends EmojiFlavor>(): (ctx: C, next: NextFunction) => Promise<void>; export { default as Reactions } from "./reactiondata.js";