Search in sources :

Example 1 with VoiceChannelDeleteListener

use of de.btobastian.javacord.listener.voicechannel.VoiceChannelDeleteListener in project Javacord by BtoBastian.

the class ChannelDeleteHandler method handleServerVoiceChannel.

/**
 * Handles the server voice channels.
 *
 * @param packet The packet (the "d"-object).
 * @param server The server of the channel.
 */
private void handleServerVoiceChannel(JSONObject packet, Server server) {
    final VoiceChannel channel = server.getVoiceChannelById(packet.getString("id"));
    if (channel == null) {
        return;
    }
    ((ImplServer) server).removeVoiceChannel(channel);
    listenerExecutorService.submit(new Runnable() {

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

Aggregations

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