mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +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 {
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user