This commit is contained in:
hydrabolt
2016-04-16 22:58:49 +01:00
commit 9956e43c8e
43 changed files with 1634 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
'use strict';
const AbstractHandler = require('./AbstractHandler');
const Structure = name => require(`../../../../structures/${name}`);
const ClientUser = Structure('ClientUser');
const Guild = Structure('Guild');
const Constants = require('../../../../util/Constants');
class GuildDeleteHandler extends AbstractHandler {
constructor(packetManager) {
super(packetManager);
}
handle(packet) {
let data = packet.d;
let client = this.packetManager.client;
let guild = client.store.get('guilds', data.id);
if (guild) {
if (guild.available && data.unavailable) {
// guild is unavailable
guild.available = false;
client.emit(Constants.Events.GUILD_UNAVAILABLE, guild);
} else {
// delete guild
client.store.KillGuild(guild);
}
} else {
// it's not there! :(
client.emit('warn', 'guild deleted but not cached in first place. missed packet?');
}
}
};
module.exports = GuildDeleteHandler;