mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +01:00
fix(MessageDeleteBulkAction): remove bulkDeleted messages from cache
Fixes #2382
This commit is contained in:
@@ -5,16 +5,15 @@ const Constants = require('../../util/Constants');
|
|||||||
class MessageDeleteBulkAction extends Action {
|
class MessageDeleteBulkAction extends Action {
|
||||||
handle(data) {
|
handle(data) {
|
||||||
const messages = new Collection();
|
const messages = new Collection();
|
||||||
|
const channel = this.client.channels.get(data.channel_id);
|
||||||
|
|
||||||
if (!data.messages) {
|
if (channel) {
|
||||||
const channel = this.client.channels.get(data.channel_id);
|
|
||||||
for (const id of data.ids) {
|
for (const id of data.ids) {
|
||||||
const message = channel.messages.get(id);
|
const message = channel.messages.get(id);
|
||||||
if (message) messages.set(message.id, message);
|
if (message) {
|
||||||
}
|
messages.set(message.id, message);
|
||||||
} else {
|
channel.messages.delete(id);
|
||||||
for (const msg of data.messages) {
|
}
|
||||||
messages.set(msg.id, msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,12 +172,13 @@ class RESTMethods {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bulkDeleteMessages(channel, messages) {
|
bulkDeleteMessages(channel, messages) {
|
||||||
|
const ids = messages.map(m => m.id);
|
||||||
return this.rest.makeRequest('post', Endpoints.Channel(channel).messages.bulkDelete, true, {
|
return this.rest.makeRequest('post', Endpoints.Channel(channel).messages.bulkDelete, true, {
|
||||||
messages: messages.map(m => m.id),
|
messages: ids,
|
||||||
}).then(() =>
|
}).then(() =>
|
||||||
this.client.actions.MessageDeleteBulk.handle({
|
this.client.actions.MessageDeleteBulk.handle({
|
||||||
channel_id: channel.id,
|
channel_id: channel.id,
|
||||||
messages,
|
ids,
|
||||||
}).messages
|
}).messages
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user