use of de.btobastian.javacord.listener.message.MessageDeleteListener in project Javacord by BtoBastian.
the class MessageBulkDeleteHandler method handle.
@Override
public void handle(JSONObject packet) {
JSONArray messageIds = packet.getJSONArray("ids");
for (int i = 0; i < messageIds.length(); i++) {
String messageId = messageIds.getString(i);
final Message message = api.getMessageById(messageId);
if (message == null) {
// no cached version available
return;
}
listenerExecutorService.submit(new Runnable() {
@Override
public void run() {
List<MessageDeleteListener> listeners = api.getListeners(MessageDeleteListener.class);
synchronized (listeners) {
for (MessageDeleteListener listener : listeners) {
try {
listener.onMessageDelete(api, message);
} catch (Throwable t) {
logger.warn("Uncaught exception in MessageDeleteListener!", t);
}
}
}
}
});
}
}
use of de.btobastian.javacord.listener.message.MessageDeleteListener in project Javacord by BtoBastian.
the class MessageDeleteHandler method handle.
@Override
public void handle(JSONObject packet) {
String messageId = packet.getString("id");
final Message message = api.getMessageById(messageId);
if (message == null) {
// no cached version available
return;
}
synchronized (message) {
if (message.isDeleted()) {
// already called listener
return;
} else {
((ImplMessage) message).setDeleted(true);
}
}
listenerExecutorService.submit(new Runnable() {
@Override
public void run() {
List<MessageDeleteListener> listeners = api.getListeners(MessageDeleteListener.class);
synchronized (listeners) {
for (MessageDeleteListener listener : listeners) {
try {
listener.onMessageDelete(api, message);
} catch (Throwable t) {
logger.warn("Uncaught exception in MessageDeleteListener!", t);
}
}
}
}
});
}
Aggregations