mirror of
https://github.com/danbulant/discord.js
synced 2026-05-25 13:02:38 +00:00
38 lines
764 B
JavaScript
38 lines
764 B
JavaScript
const Action = require('./Action');
|
|
const Constants = require('../../util/Constants');
|
|
const cloneObject = require('../../util/CloneObject');
|
|
|
|
class GuildUpdateAction extends Action {
|
|
|
|
constructor(client) {
|
|
super(client);
|
|
this.deleted = {};
|
|
this.timeouts = [];
|
|
}
|
|
|
|
handle(data) {
|
|
const client = this.client;
|
|
const guild = client.store.get('guilds', data.id);
|
|
|
|
if (guild) {
|
|
const oldGuild = cloneObject(guild);
|
|
guild.setup(data);
|
|
|
|
if (!oldGuild.equals(data)) {
|
|
client.emit(Constants.Events.GUILD_UPDATE, oldGuild, guild);
|
|
}
|
|
|
|
return {
|
|
old: oldGuild,
|
|
updated: guild,
|
|
};
|
|
}
|
|
|
|
return {
|
|
old: null,
|
|
updated: null,
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = GuildUpdateAction;
|