mirror of
https://github.com/danbulant/discord.js
synced 2026-05-27 22:11:53 +00:00
fix(MessageDeleteBulkAction): remove bulkDeleted messages from cache
Fixes #2382
This commit is contained in:
parent
c387e96078
commit
7c37a0d386
2 changed files with 9 additions and 9 deletions
|
|
@ -5,16 +5,15 @@ const Constants = require('../../util/Constants');
|
|||
class MessageDeleteBulkAction extends Action {
|
||||
handle(data) {
|
||||
const messages = new Collection();
|
||||
const channel = this.client.channels.get(data.channel_id);
|
||||
|
||||
if (!data.messages) {
|
||||
const channel = this.client.channels.get(data.channel_id);
|
||||
if (channel) {
|
||||
for (const id of data.ids) {
|
||||
const message = channel.messages.get(id);
|
||||
if (message) messages.set(message.id, message);
|
||||
}
|
||||
} else {
|
||||
for (const msg of data.messages) {
|
||||
messages.set(msg.id, msg);
|
||||
if (message) {
|
||||
messages.set(message.id, message);
|
||||
channel.messages.delete(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -172,12 +172,13 @@ class RESTMethods {
|
|||
}
|
||||
|
||||
bulkDeleteMessages(channel, messages) {
|
||||
const ids = messages.map(m => m.id);
|
||||
return this.rest.makeRequest('post', Endpoints.Channel(channel).messages.bulkDelete, true, {
|
||||
messages: messages.map(m => m.id),
|
||||
messages: ids,
|
||||
}).then(() =>
|
||||
this.client.actions.MessageDeleteBulk.handle({
|
||||
channel_id: channel.id,
|
||||
messages,
|
||||
ids,
|
||||
}).messages
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue