Add textBasedChannel.bulkDelete()

This commit is contained in:
Amish Shah
2016-08-26 22:13:23 +01:00
parent b22bda74b8
commit 642d768cdc
13 changed files with 111 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ class ActionsManager {
this.register('MessageCreate');
this.register('MessageDelete');
this.register('MessageDeleteBulk');
this.register('MessageUpdate');
this.register('ChannelCreate');
this.register('ChannelDelete');

View File

@@ -0,0 +1,33 @@
const Action = require('./Action');
const Collection = require('../../util/Collection');
const Constants = require('../../util/Constants');
class MessageDeleteBulkAction extends Action {
constructor(client) {
super(client);
this.timeouts = [];
this.deleted = {};
}
handle(data) {
const client = this.client;
const channel = client.channels.get(data.channel_id);
const ids = data.ids;
const messages = new Collection();
for (const id of ids) {
const message = channel.messages.get(id);
if (message) {
messages.set(message.id, message);
}
}
if (messages.size > 0) {
client.emit(Constants.Events.MESSAGE_BULK_DELETE, messages);
}
return {
messages,
};
}
}
module.exports = MessageDeleteBulkAction;