use of de.btobastian.javacord.entities.message.impl.ImplMessage in project Javacord by BtoBastian.
the class MessageReactionRemoveAllHandler method handle.
@Override
public void handle(JSONObject packet) {
// {"message_id":"269166028959776768","channel_id":"81402706320699392"}
String messageId = packet.getString("message_id");
final Message message = api.getMessageById(messageId);
if (message == null) {
return;
}
final List<Reaction> reactions = message.getReactions();
((ImplMessage) message).removeAllReactionsFromCache();
listenerExecutorService.submit(new Runnable() {
@Override
public void run() {
List<ReactionRemoveAllListener> listeners = api.getListeners(ReactionRemoveAllListener.class);
synchronized (listeners) {
for (ReactionRemoveAllListener listener : listeners) {
try {
listener.onReactionRemoveAll(api, message, reactions);
} catch (Throwable t) {
logger.warn("Uncaught exception in ReactionRemoveAllListener!", t);
}
}
}
}
});
}
use of de.btobastian.javacord.entities.message.impl.ImplMessage 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