use of de.btobastian.javacord.listener.message.TypingStartListener in project Javacord by BtoBastian.
the class TypingStartHandler method handle.
@Override
public void handle(JSONObject packet) {
Channel channelTemp = null;
String channelId = packet.getString("channel_id");
Iterator<Server> serverIterator = api.getServers().iterator();
while (serverIterator.hasNext()) {
channelTemp = serverIterator.next().getChannelById(channelId);
if (channelTemp != null) {
break;
}
}
final Channel channel = channelTemp;
String userId = packet.getString("user_id");
final User user;
try {
user = api.getUserById(userId).get();
} catch (InterruptedException | ExecutionException e) {
return;
}
listenerExecutorService.submit(new Runnable() {
@Override
public void run() {
List<TypingStartListener> listeners = api.getListeners(TypingStartListener.class);
synchronized (listeners) {
for (TypingStartListener listener : listeners) {
try {
listener.onTypingStart(api, user, channel);
} catch (Throwable t) {
logger.warn("Uncaught exception in TypingStartListener!", t);
}
}
}
}
});
}
Aggregations