use of io.discloader.discloader.common.event.channel.ChannelDeleteEvent in project DiscLoader by R3alCl0ud.
the class ChannelDelete method handle.
@Override
public void handle(SocketPacket packet) {
String d = gson.toJson(packet.d);
ChannelJSON data = gson.fromJson(d, ChannelJSON.class);
IGuild guild = null;
IChannel channel = null;
if (data.guild_id != null) {
guild = EntityRegistry.getGuildByID(data.guild_id);
channel = EntityRegistry.addChannel(data, loader, guild);
} else {
channel = EntityRegistry.addChannel(data, loader);
}
switch(channel.getType()) {
case TEXT:
guild.getTextChannels().remove(channel.getID());
break;
case VOICE:
guild.getVoiceChannels().remove(channel.getID());
break;
default:
EntityRegistry.removeChannel(channel);
break;
}
ChannelDeleteEvent event = new ChannelDeleteEvent(channel);
loader.emit(Events.CHANNEL_DELETE, event);
loader.emit(event);
}
Aggregations