Search in sources :

Example 1 with MessageCreateListener

use of de.btobastian.javacord.listener.message.MessageCreateListener in project Javacord by BtoBastian.

the class MessageCreateHandler method handle.

@Override
public void handle(JSONObject packet) {
    String messageId = packet.getString("id");
    Message messageTemp = api.getMessageById(messageId);
    if (messageTemp == null) {
        messageTemp = new ImplMessage(packet, api, null);
    }
    final Message message = messageTemp;
    listenerExecutorService.submit(new Runnable() {

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

Aggregations

Message (de.btobastian.javacord.entities.message.Message)1 ImplMessage (de.btobastian.javacord.entities.message.impl.ImplMessage)1 MessageCreateListener (de.btobastian.javacord.listener.message.MessageCreateListener)1 List (java.util.List)1