mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
fix(TextChannel#bulkDelete): use GenericAction#getMessage to handle return value correctly (#3664)
* Corrected the handling of the action * Apply same fix to handling of single message in bulkDelete * Revert to using await
This commit is contained in:
@@ -306,19 +306,16 @@ class TextBasedChannel {
|
|||||||
if (messageIDs.length === 0) return new Collection();
|
if (messageIDs.length === 0) return new Collection();
|
||||||
if (messageIDs.length === 1) {
|
if (messageIDs.length === 1) {
|
||||||
await this.client.api.channels(this.id).messages(messageIDs[0]).delete();
|
await this.client.api.channels(this.id).messages(messageIDs[0]).delete();
|
||||||
const message = this.client.actions.MessageDelete.handle({
|
const message = this.client.actions.MessageDelete.getMessage({
|
||||||
channel_id: this.id,
|
message_id: messageIDs[0],
|
||||||
id: messageIDs[0],
|
}, this);
|
||||||
}).message;
|
return message ? new Collection([[message.id, message]]) : new Collection();
|
||||||
if (message) return new Collection([[message.id, message]]);
|
|
||||||
return new Collection();
|
|
||||||
}
|
}
|
||||||
await this.client.api.channels[this.id].messages['bulk-delete']
|
await this.client.api.channels[this.id].messages['bulk-delete']
|
||||||
.post({ data: { messages: messageIDs } });
|
.post({ data: { messages: messageIDs } });
|
||||||
return this.client.actions.MessageDeleteBulk.handle({
|
return messageIDs.reduce((col, id) => col.set(id, this.client.actions.MessageDeleteBulk.getMessage({
|
||||||
channel_id: this.id,
|
message_id: id,
|
||||||
ids: messageIDs,
|
}, this)), new Collection());
|
||||||
}).messages;
|
|
||||||
}
|
}
|
||||||
if (!isNaN(messages)) {
|
if (!isNaN(messages)) {
|
||||||
const msgs = await this.messages.fetch({ limit: messages });
|
const msgs = await this.messages.fetch({ limit: messages });
|
||||||
|
|||||||
Reference in New Issue
Block a user