Search in sources :

Example 1 with ReactionRemoveAllListener

use of de.btobastian.javacord.listener.message.ReactionRemoveAllListener 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);
                    }
                }
            }
        }
    });
}
Also used : ImplMessage(de.btobastian.javacord.entities.message.impl.ImplMessage) Message(de.btobastian.javacord.entities.message.Message) ImplMessage(de.btobastian.javacord.entities.message.impl.ImplMessage) List(java.util.List) ReactionRemoveAllListener(de.btobastian.javacord.listener.message.ReactionRemoveAllListener) Reaction(de.btobastian.javacord.entities.message.Reaction)

Aggregations

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