mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 20:43:30 +01:00
feat(Actions): use partials for messageDeleteBulk (#3240)
* make use of partials * don't cache the messages * pass each message within the for..of iteration
This commit is contained in:
@@ -33,14 +33,14 @@ class GenericAction {
|
|||||||
this.client.channels.get(id));
|
this.client.channels.get(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
getMessage(data, channel) {
|
getMessage(data, channel, cache = true) {
|
||||||
const id = data.message_id || data.id;
|
const id = data.message_id || data.id;
|
||||||
return data.message || (this.client.options.partials.includes(PartialTypes.MESSAGE) ?
|
return data.message || (this.client.options.partials.includes(PartialTypes.MESSAGE) ?
|
||||||
channel.messages.add({
|
channel.messages.add({
|
||||||
id,
|
id,
|
||||||
channel_id: channel.id,
|
channel_id: channel.id,
|
||||||
guild_id: data.guild_id || (channel.guild ? channel.guild.id : null),
|
guild_id: data.guild_id || (channel.guild ? channel.guild.id : null),
|
||||||
}) :
|
}, cache) :
|
||||||
channel.messages.get(id));
|
channel.messages.get(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ class MessageDeleteBulkAction extends Action {
|
|||||||
const ids = data.ids;
|
const ids = data.ids;
|
||||||
const messages = new Collection();
|
const messages = new Collection();
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
const message = channel.messages.get(id);
|
const message = this.getMessage({
|
||||||
|
id,
|
||||||
|
guild_id: data.guild_id,
|
||||||
|
}, channel, false);
|
||||||
if (message) {
|
if (message) {
|
||||||
message.deleted = true;
|
message.deleted = true;
|
||||||
messages.set(message.id, message);
|
messages.set(message.id, message);
|
||||||
|
|||||||
Reference in New Issue
Block a user