Search in sources :

Example 1 with VoiceChannelCreateListener

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

the class ChannelCreateHandler 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) {
    if (server.getVoiceChannelById(packet.getString("id")) != null) {
        return;
    }
    final VoiceChannel channel = new ImplVoiceChannel(packet, (ImplServer) server, api);
    listenerExecutorService.submit(new Runnable() {

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

Aggregations

VoiceChannel (de.btobastian.javacord.entities.VoiceChannel)1 ImplVoiceChannel (de.btobastian.javacord.entities.impl.ImplVoiceChannel)1 VoiceChannelCreateListener (de.btobastian.javacord.listener.voicechannel.VoiceChannelCreateListener)1 List (java.util.List)1