use of de.btobastian.javacord.listener.message.MessageEditListener in project Javacord by BtoBastian.
the class MessageUpdateHandler method handle.
@Override
public void handle(JSONObject packet) {
String messageId = packet.getString("id");
final Message message = api.getMessageById(messageId);
if (message == null) {
return;
}
final String oldContent = message.getContent();
if (!packet.has("content")) {
return;
}
((ImplMessage) message).setContent(packet.getString("content"));
listenerExecutorService.submit(new Runnable() {
@Override
public void run() {
List<MessageEditListener> listeners = api.getListeners(MessageEditListener.class);
synchronized (listeners) {
for (MessageEditListener listener : listeners) {
try {
listener.onMessageEdit(api, message, oldContent);
} catch (Throwable t) {
logger.warn("Uncaught exception in MessageEditListener!", t);
}
}
}
}
});
}
Aggregations