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);
}
}
}
}
});
}
Aggregations