Skip to content
GitHub

ReactionHandler

function in meocord/decorator Since 4.0.0

ReactionHandler<
  T extends MessageReaction | PartialMessageReaction,
  R,
>(
  emoji?: string,
  settings?: ReactionHandlerSettings,
): ReactionHandlerDecorator<T, R>

ReactionHandler<
  T extends MessageReaction | PartialMessageReaction,
  R,
>(settings: ReactionHandlerSettings): ReactionHandlerDecorator<T, R>

Runs the method it decorates when a reaction with an emoji is added to or removed from a message.

Use it to act on reactions: a starboard, a poll, a role menu or approving by ✅. Leave the emoji out to run for every reaction. For clicks on a message's buttons, use Command with a customId.

Where it runs

Parameters

NameTypeDefaultSinceDescription
emoji?string

The emoji to handle: its character, or a custom emoji's id, <:name:id> or name.

settings?ReactionHandlerSettings4.1.0

Whether bots' reactions reach it too; see ReactionHandlerSettings.

settings.bots?booleanfalse4.1.0

Also runs for reactions from bots, the bot's own included, which are skipped by default as messages from bots are.

Returns

ReactionHandlerDecorator<T, R>

Examples

TypeScript
@ReactionHandler('⭐')
async star(reaction: MessageReaction, { user, action }: ReactionEvent) {
  if (action === ReactionHandlerAction.ADD) await reaction.message.reply(`${user.username} starred this.`)
}

Parameters

NameTypeDefaultSinceDescription
settingsReactionHandlerSettings4.1.0

Whether bots' reactions reach it too; see ReactionHandlerSettings.

settings.bots?booleanfalse4.1.0

Also runs for reactions from bots, the bot's own included, which are skipped by default as messages from bots are.

Returns

ReactionHandlerDecorator<T, R>