buddy

node MVC discord bot
Log | Files | Refs | README

MessageReactionRemoveEmoji.js (905B)


      1 'use strict';
      2 
      3 const Action = require('./Action');
      4 const { Events } = require('../../util/Constants');
      5 
      6 class MessageReactionRemoveEmoji extends Action {
      7   handle(data) {
      8     const channel = this.getChannel(data);
      9     if (!channel || channel.type === 'voice') return false;
     10 
     11     const message = this.getMessage(data, channel);
     12     if (!message) return false;
     13 
     14     const reaction = this.getReaction(data, message);
     15     if (!reaction) return false;
     16     if (!message.partial) message.reactions.cache.delete(reaction.emoji.id || reaction.emoji.name);
     17 
     18     /**
     19      * Emitted when a bot removes an emoji reaction from a cached message.
     20      * @event Client#messageReactionRemoveEmoji
     21      * @param {MessageReaction} reaction The reaction that was removed
     22      */
     23     this.client.emit(Events.MESSAGE_REACTION_REMOVE_EMOJI, reaction);
     24     return { reaction };
     25   }
     26 }
     27 
     28 module.exports = MessageReactionRemoveEmoji;