mirror of
https://github.com/discordjs/discord.js.git
synced 2026-06-03 01:20:07 +00:00
35 lines
864 B
JavaScript
35 lines
864 B
JavaScript
const Action = require('./Action');
|
|
const Constants = require('../../util/Constants');
|
|
const Util = require('../../util/Util');
|
|
|
|
class ChannelUpdateAction extends Action {
|
|
handle(data) {
|
|
const client = this.client;
|
|
|
|
const channel = client.channels.get(data.id);
|
|
if (channel) {
|
|
const oldChannel = Util.cloneObject(channel);
|
|
channel.setup(data);
|
|
client.emit(Constants.Events.CHANNEL_UPDATE, oldChannel, channel);
|
|
return {
|
|
old: oldChannel,
|
|
updated: channel,
|
|
};
|
|
}
|
|
|
|
return {
|
|
old: null,
|
|
updated: null,
|
|
};
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Emitted whenever a channel is updated - e.g. name change, topic change.
|
|
* @event Client#channelUpdate
|
|
* @param {Channel} oldChannel The channel before the update
|
|
* @param {Channel} newChannel The channel after the update
|
|
*/
|
|
|
|
module.exports = ChannelUpdateAction;
|