mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
I think I got ChannelUpdate working??
This commit is contained in:
@@ -11,6 +11,7 @@ class ActionsManager {
|
||||
this.register('MessageUpdate');
|
||||
this.register('ChannelCreate');
|
||||
this.register('ChannelDelete');
|
||||
this.register('ChannelUpdate');
|
||||
}
|
||||
|
||||
register(name) {
|
||||
|
||||
39
src/client/actions/ChannelUpdate.js
Normal file
39
src/client/actions/ChannelUpdate.js
Normal 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;
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user