mirror of
https://github.com/danbulant/discord.js
synced 2026-05-25 21:12:06 +00:00
34 lines
810 B
JavaScript
34 lines
810 B
JavaScript
const Action = require('./Action');
|
|
const Constants = require('../../util/Constants');
|
|
const Util = require('../../util/Util');
|
|
|
|
class GuildUpdateAction extends Action {
|
|
handle(data) {
|
|
const client = this.client;
|
|
|
|
const guild = client.guilds.get(data.id);
|
|
if (guild) {
|
|
const oldGuild = Util.cloneObject(guild);
|
|
guild.setup(data);
|
|
client.emit(Constants.Events.GUILD_UPDATE, oldGuild, guild);
|
|
return {
|
|
old: oldGuild,
|
|
updated: guild,
|
|
};
|
|
}
|
|
|
|
return {
|
|
old: null,
|
|
updated: null,
|
|
};
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Emitted whenever a guild is updated - e.g. name change.
|
|
* @event Client#guildUpdate
|
|
* @param {Guild} oldGuild The guild before the update.
|
|
* @param {Guild} newGuild The guild after the update.
|
|
*/
|
|
|
|
module.exports = GuildUpdateAction;
|