mirror of
https://github.com/danbulant/discord.js
synced 2026-05-24 20:42:27 +00:00
Add Message.edits (#636)
* Add Message.edits * Make travis happy * Change @type for consistency
This commit is contained in:
parent
e4cac2d575
commit
17bee8084e
2 changed files with 12 additions and 0 deletions
|
|
@ -12,6 +12,7 @@ class MessageUpdateAction extends Action {
|
|||
if (message && !message.equals(data, true)) {
|
||||
const oldMessage = cloneObject(message);
|
||||
message.patch(data);
|
||||
message._edits.unshift(oldMessage);
|
||||
client.emit(Constants.Events.MESSAGE_UPDATE, oldMessage, message);
|
||||
return {
|
||||
old: oldMessage,
|
||||
|
|
|
|||
|
|
@ -123,6 +123,8 @@ class Message {
|
|||
}
|
||||
}
|
||||
|
||||
this._edits = [];
|
||||
|
||||
/**
|
||||
* Whether or not this message was sent by Discord, not actually a user (e.g. pin notifications)
|
||||
* @type {boolean}
|
||||
|
|
@ -147,6 +149,15 @@ class Message {
|
|||
return new Date(this._editedTimestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of cached versions of the message, including the current version.
|
||||
* Sorted from latest (first) to oldest (last).
|
||||
* @type {Message[]}
|
||||
*/
|
||||
get edits() {
|
||||
return this._edits.slice().unshift(this);
|
||||
}
|
||||
|
||||
patch(data) { // eslint-disable-line complexity
|
||||
if (data.author) {
|
||||
this.author = this.client.users.get(data.author.id);
|
||||
|
|
|
|||
Loading…
Reference in a new issue