2022-03-19 17:37:45 +07:00
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
const Action = require('./Action');
|
2022-03-24 17:55:32 +07:00
|
|
|
|
const { Events } = require('../../util/Constants');
|
2022-03-19 17:37:45 +07:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
{ user_id: 'id',
|
|
|
|
|
|
message_id: 'id',
|
|
|
|
|
|
emoji: { name: '<27>', id: null },
|
|
|
|
|
|
channel_id: 'id',
|
|
|
|
|
|
guild_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);
|
2022-03-24 17:55:32 +07:00
|
|
|
|
if (!channel || !channel.isText()) return false;
|
2022-03-19 17:37:45 +07:00
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
*/
|
2022-03-24 17:55:32 +07:00
|
|
|
|
this.client.emit(Events.MESSAGE_REACTION_REMOVE, reaction, user);
|
2022-03-19 17:37:45 +07:00
|
|
|
|
|
|
|
|
|
|
return { message, reaction, user };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = MessageReactionRemove;
|