mirror of
https://github.com/danbulant/discord.js
synced 2026-06-24 17:21:59 +00:00
* chore: consistency/prettier * chore: rebase * chore: rebase * chore: include typings * fix: include typings file in prettier lint-staged
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
'use strict';
|
||
|
||
const Action = require('./Action');
|
||
const { Events } = require('../../util/Constants');
|
||
|
||
/*
|
||
{ user_id: 'id',
|
||
message_id: 'id',
|
||
emoji: { name: '<27>', id: null },
|
||
channel_id: 'id' } }
|
||
*/
|
||
|
||
class MessageReactionRemove extends Action {
|
||
handle(data) {
|
||
if (!data.emoji) return false;
|
||
|
||
const user = this.getUser(data);
|
||
if (!user) return false;
|
||
|
||
// Verify channel
|
||
const channel = this.getChannel(data);
|
||
if (!channel || channel.type === 'voice') return false;
|
||
|
||
// Verify message
|
||
const message = this.getMessage(data, channel);
|
||
if (!message) return false;
|
||
|
||
// Verify reaction
|
||
const reaction = this.getReaction(data, message, user);
|
||
if (!reaction) return false;
|
||
reaction._remove(user);
|
||
/**
|
||
* Emitted whenever a reaction is removed from a cached message.
|
||
* @event Client#messageReactionRemove
|
||
* @param {MessageReaction} messageReaction The reaction object
|
||
* @param {User} user The user whose emoji or reaction emoji was removed
|
||
*/
|
||
this.client.emit(Events.MESSAGE_REACTION_REMOVE, reaction, user);
|
||
|
||
return { message, reaction, user };
|
||
}
|
||
}
|
||
|
||
module.exports = MessageReactionRemove;
|