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
- The handler — after every stage the call passed
Parameters
| Name | Type | Default | Since | Description |
|---|---|---|---|---|
emoji? | string | The emoji to handle: its character, or a custom emoji's id, | ||
settings? | ReactionHandlerSettings | 4.1.0 | Whether bots' reactions reach it too; see | |
settings.bots? | boolean | false | 4.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
@ReactionHandler('⭐')
async star(reaction: MessageReaction, { user, action }: ReactionEvent) {
if (action === ReactionHandlerAction.ADD) await reaction.message.reply(`${user.username} starred this.`)
}Parameters
| Name | Type | Default | Since | Description |
|---|---|---|---|---|
settings | ReactionHandlerSettings | 4.1.0 | Whether bots' reactions reach it too; see | |
settings.bots? | boolean | false | 4.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>