use of io.discloader.discloader.common.event.guild.GuildDeleteEvent in project DiscLoader by R3alCl0ud.
the class GuildDelete method handle.
@Override
public void handle(SocketPacket packet) {
String d = this.gson.toJson(packet.d);
GuildJSON data = this.gson.fromJson(d, GuildJSON.class);
IGuild guild = null;
if (EntityRegistry.guildExists(data.id)) {
guild = EntityRegistry.getGuildByID(data.id);
guild.setup(data);
} else {
guild = EntityRegistry.addGuild(data);
}
if (!guild.isAvailable()) {
EntityRegistry.removeGuild(guild);
if (socket.status == Status.READY && loader.ready) {
GuildDeleteEvent event = new GuildDeleteEvent(guild);
loader.emit(Events.GUILD_DELETE, event);
for (IEventListener e : loader.handlers) {
e.GuildDelete(event);
}
}
}
}
Aggregations