-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(MessageReaction): add remove method and Client#messageReactionRe…
…moveEmoji (#3723) * Add support for MessageReaction#remove and MESSAGE_REACTION_REMOVE_EMOJI * Remove reaction from cache Co-Authored-By: matthewfripp <[email protected]> * fix: message may be partial * Clarify what the event entails * Document client in MessageReaction Co-Authored-By: SpaceEEC <[email protected]> * await the REST call * Add MessageReaction#remove to typings Co-authored-by: matthewfripp <[email protected]> Co-authored-by: SpaceEEC <[email protected]>
- Loading branch information
1 parent
d8b4725
commit 030d263
Showing
7 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
const Action = require('./Action'); | ||
const { Events } = require('../../util/Constants'); | ||
|
||
class MessageReactionRemoveEmoji extends Action { | ||
handle(data) { | ||
const channel = this.getChannel(data); | ||
if (!channel || channel.type === 'voice') return false; | ||
|
||
const message = this.getMessage(data, channel); | ||
if (!message) return false; | ||
|
||
const reaction = this.getReaction(data, message); | ||
if (!reaction) return false; | ||
if (!message.partial) message.reactions.delete(reaction.emoji.id || reaction.emoji.name); | ||
|
||
/** | ||
* Emitted when a bot removes an emoji reaction from a cached message. | ||
* @event Client#messageReactionRemoveEmoji | ||
* @param {MessageReaction} reaction The reaction that was removed | ||
*/ | ||
this.client.emit(Events.MESSAGE_REACTION_REMOVE_EMOJI, reaction); | ||
return { reaction }; | ||
} | ||
} | ||
|
||
module.exports = MessageReactionRemoveEmoji; |
5 changes: 5 additions & 0 deletions
5
src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = (client, packet) => { | ||
client.actions.MessageReactionRemoveEmoji.handle(packet.d); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters