use of org.javacord.core.event.user.UserStartTypingEventImpl in project Javacord by BtoBastian.
the class TypingStartHandler method handle.
@Override
public void handle(JsonNode packet) {
long userId = packet.get("user_id").asLong();
long channelId = packet.get("channel_id").asLong();
TextChannel channel = api.getTextChannelById(channelId).orElse(null);
ServerImpl server = null;
if (packet.hasNonNull("guild_id")) {
long serverId = packet.get("guild_id").asLong();
server = (ServerImpl) api.getPossiblyUnreadyServerById(serverId).orElseThrow(AssertionError::new);
}
MemberImpl member = null;
if (packet.hasNonNull("member") && server != null) {
member = new MemberImpl(api, server, packet.get("member"), null);
}
if (channel != null) {
UserStartTypingEvent event = new UserStartTypingEventImpl(channel, userId, member);
api.getEventDispatcher().dispatchUserStartTypingEvent(server != null ? server : api, server, channel, userId, event);
}
}
Aggregations