GuildUpdate.js (765B)
1 'use strict'; 2 3 const Action = require('./Action'); 4 const { Events } = require('../../util/Constants'); 5 6 class GuildUpdateAction extends Action { 7 handle(data) { 8 const client = this.client; 9 10 const guild = client.guilds.cache.get(data.id); 11 if (guild) { 12 const old = guild._update(data); 13 /** 14 * Emitted whenever a guild is updated - e.g. name change. 15 * @event Client#guildUpdate 16 * @param {Guild} oldGuild The guild before the update 17 * @param {Guild} newGuild The guild after the update 18 */ 19 client.emit(Events.GUILD_UPDATE, old, guild); 20 return { 21 old, 22 updated: guild, 23 }; 24 } 25 26 return { 27 old: null, 28 updated: null, 29 }; 30 } 31 } 32 33 module.exports = GuildUpdateAction;