mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
Add Message.edits (#636)
* Add Message.edits * Make travis happy * Change @type for consistency
This commit is contained in:
committed by
Schuyler Cebulskie
parent
e4cac2d575
commit
17bee8084e
@@ -12,6 +12,7 @@ class MessageUpdateAction extends Action {
|
|||||||
if (message && !message.equals(data, true)) {
|
if (message && !message.equals(data, true)) {
|
||||||
const oldMessage = cloneObject(message);
|
const oldMessage = cloneObject(message);
|
||||||
message.patch(data);
|
message.patch(data);
|
||||||
|
message._edits.unshift(oldMessage);
|
||||||
client.emit(Constants.Events.MESSAGE_UPDATE, oldMessage, message);
|
client.emit(Constants.Events.MESSAGE_UPDATE, oldMessage, message);
|
||||||
return {
|
return {
|
||||||
old: oldMessage,
|
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)
|
* Whether or not this message was sent by Discord, not actually a user (e.g. pin notifications)
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
@@ -147,6 +149,15 @@ class Message {
|
|||||||
return new Date(this._editedTimestamp);
|
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
|
patch(data) { // eslint-disable-line complexity
|
||||||
if (data.author) {
|
if (data.author) {
|
||||||
this.author = this.client.users.get(data.author.id);
|
this.author = this.client.users.get(data.author.id);
|
||||||
|
|||||||
Reference in New Issue
Block a user