Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more
Module

x/grammy/context.ts>Context#reactions

The Telegram Bot Framework.
Very Popular
Go to Latest
method Context.prototype.reactions
import { Context } from "https://deno.land/x/grammy@v1.31.2/context.ts";

Find out which reactions were added and removed in a message_reaction update. This method looks at ctx.messageReaction and computes the difference between the old reaction and the new reaction. It also groups the reactions by emoji reactions and custom emoji reactions. For example, the resulting object could look like this:

{
  emoji: ['πŸ‘', 'πŸŽ‰']
  emojiAdded: ['πŸŽ‰'],
  emojiKept: ['πŸ‘'],
  emojiRemoved: [],
  customEmoji: [],
  customEmojiAdded: [],
  customEmojiKept: [],
  customEmojiRemoved: ['id0123'],
  paid: true,
  paidAdded: false,
  paidRemoved: false,
}

In the above example, a tada reaction was added by the user, and a custom emoji reaction with the custom emoji 'id0123' was removed in the same update. The user had already reacted with a thumbs up reaction and a paid star reaction, which they left both unchanged. As a result, the current reaction by the user is thumbs up, tada, and a paid reaction. Note that the current reaction (all emoji reactions regardless of type in one list) can also be obtained from ctx.messageReaction.new_reaction.

Remember that reaction updates only include information about the reaction of a specific user. The respective message may have many more reactions by other people which will not be included in this update.

Returns

{ emoji: ReactionTypeEmoji["emoji"][]; emojiAdded: ReactionTypeEmoji["emoji"][]; emojiKept: ReactionTypeEmoji["emoji"][]; emojiRemoved: ReactionTypeEmoji["emoji"][]; customEmoji: string[]; customEmojiAdded: string[]; customEmojiKept: string[]; customEmojiRemoved: string[]; paid: boolean; paidAdded: boolean; }

An object containing information about the reaction update