Skip to content

Commit

Permalink
fix(TextChannel#bulkDelete): use GenericAction#getMessage to handle r…
Browse files Browse the repository at this point in the history
…eturn value correctly (#3664)

* Corrected the handling of the action

* Apply same fix to handling of single message in bulkDelete

* Revert to using await
  • Loading branch information
monbrey authored and SpaceEEC committed Jan 25, 2020
1 parent 3ea9ac5 commit d8b4725
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/structures/interfaces/TextBasedChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,19 +306,16 @@ class TextBasedChannel {
if (messageIDs.length === 0) return new Collection();
if (messageIDs.length === 1) {
await this.client.api.channels(this.id).messages(messageIDs[0]).delete();
const message = this.client.actions.MessageDelete.handle({
channel_id: this.id,
id: messageIDs[0],
}).message;
if (message) return new Collection([[message.id, message]]);
return new Collection();
const message = this.client.actions.MessageDelete.getMessage({
message_id: messageIDs[0],
}, this);
return message ? new Collection([[message.id, message]]) : new Collection();
}
await this.client.api.channels[this.id].messages['bulk-delete']
.post({ data: { messages: messageIDs } });
return this.client.actions.MessageDeleteBulk.handle({
channel_id: this.id,
ids: messageIDs,
}).messages;
return messageIDs.reduce((col, id) => col.set(id, this.client.actions.MessageDeleteBulk.getMessage({
message_id: id,
}, this)), new Collection());
}
if (!isNaN(messages)) {
const msgs = await this.messages.fetch({ limit: messages });
Expand Down

0 comments on commit d8b4725

Please sign in to comment.