I think I got ChannelUpdate working??

This commit is contained in:
hydrabolt
2016-04-30 18:22:09 +01:00
parent 2341c83638
commit 90cf787759
9 changed files with 130 additions and 12 deletions

View File

@@ -11,6 +11,7 @@ class ActionsManager {
this.register('MessageUpdate');
this.register('ChannelCreate');
this.register('ChannelDelete');
this.register('ChannelUpdate');
}
register(name) {

View File

@@ -0,0 +1,39 @@
'use strict';
const Action = require('./Action');
const Constants = require('../../util/Constants');
const CloneObject = require('../../util/CloneObject');
const Message = require('../../structures/Message');
class ChannelUpdateAction extends Action {
constructor(client) {
super(client);
}
handle(data) {
let client = this.client;
let channel = client.store.get('channels', data.id);
if (channel) {
let oldChannel = CloneObject(channel);
channel.setup(data);
if (!oldChannel.equals(data)) {
client.emit(Constants.Events.CHANNEL_UPDATE, oldChannel, channel);
}
return {
old: oldChannel,
updated: channel,
};
}
return {
old: null,
updated: null,
};
}
};
module.exports = ChannelUpdateAction;

View File

@@ -25,7 +25,13 @@ class MessageUpdateAction extends Action {
old: oldMessage,
updated: message,
};
client.emit(Constants.Events.MESSAGE_UPDATE, oldMessage, message);
}
return {
old: message,
updated: message,
};
}
return {