Search in sources :

Example 1 with ChannelCreateListener

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

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

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

Aggregations

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