Search in sources :

Example 1 with ChannelDeleteListener

use of de.btobastian.javacord.listener.channel.ChannelDeleteListener in project Javacord by BtoBastian.

the class ChannelDeleteHandler method handleServerTextChannel.

/**
 * Handles the server text channels.
 *
 * @param packet The packet (the "d"-object).
 * @param server The server of the channel.
 */
private void handleServerTextChannel(JSONObject packet, Server server) {
    final Channel channel = server.getChannelById(packet.getString("id"));
    if (channel == null) {
        return;
    }
    ((ImplServer) server).removeChannel(channel);
    listenerExecutorService.submit(new Runnable() {

        @Override
        public void run() {
            List<ChannelDeleteListener> listeners = api.getListeners(ChannelDeleteListener.class);
            synchronized (listeners) {
                for (ChannelDeleteListener listener : listeners) {
                    try {
                        listener.onChannelDelete(api, channel);
                    } catch (Throwable t) {
                        logger.warn("Uncaught exception in ChannelDeleteListener!", t);
                    }
                }
            }
        }
    });
}
Also used : ImplServer(de.btobastian.javacord.entities.impl.ImplServer) Channel(de.btobastian.javacord.entities.Channel) VoiceChannel(de.btobastian.javacord.entities.VoiceChannel) VoiceChannelDeleteListener(de.btobastian.javacord.listener.voicechannel.VoiceChannelDeleteListener) ChannelDeleteListener(de.btobastian.javacord.listener.channel.ChannelDeleteListener) List(java.util.List)

Aggregations

Channel (de.btobastian.javacord.entities.Channel)1 VoiceChannel (de.btobastian.javacord.entities.VoiceChannel)1 ImplServer (de.btobastian.javacord.entities.impl.ImplServer)1 ChannelDeleteListener (de.btobastian.javacord.listener.channel.ChannelDeleteListener)1 VoiceChannelDeleteListener (de.btobastian.javacord.listener.voicechannel.VoiceChannelDeleteListener)1 List (java.util.List)1