feat(Message): add messageEditHistoryMaxSize to limit stored msg edits (#4867)

This commit is contained in:
Matt (IPv4) Cowley
2020-10-17 14:34:49 +01:00
committed by GitHub
parent 4a6fb9a7d4
commit c412cd7521
5 changed files with 23 additions and 5 deletions

View File

@@ -432,6 +432,13 @@ class Client extends BaseClient {
if (typeof options.messageSweepInterval !== 'number' || isNaN(options.messageSweepInterval)) {
throw new TypeError('CLIENT_INVALID_OPTION', 'messageSweepInterval', 'a number');
}
if (
typeof options.messageEditHistoryMaxSize !== 'number' ||
isNaN(options.messageEditHistoryMaxSize) ||
options.messageEditHistoryMaxSize < -1
) {
throw new TypeError('CLIENT_INVALID_OPTION', 'messageEditHistoryMaxSize', 'a number greater than or equal to -1');
}
if (typeof options.fetchAllMembers !== 'boolean') {
throw new TypeError('CLIENT_INVALID_OPTION', 'fetchAllMembers', 'a boolean');
}

View File

@@ -9,9 +9,9 @@ class MessageUpdateAction extends Action {
const { id, channel_id, guild_id, author, timestamp, type } = data;
const message = this.getMessage({ id, channel_id, guild_id, author, timestamp, type }, channel);
if (message) {
message.patch(data);
const old = message.patch(data);
return {
old: message._edits[0],
old,
updated: message,
};
}