Search in sources :

Example 1 with ServerMemberJoinEventImpl

use of org.javacord.core.event.server.member.ServerMemberJoinEventImpl in project Javacord by BtoBastian.

the class GuildMemberAddHandler method handle.

@Override
public void handle(JsonNode packet) {
    api.getPossiblyUnreadyServerById(packet.get("guild_id").asLong()).map(server -> (ServerImpl) server).ifPresent(server -> {
        MemberImpl member = server.addMember(packet);
        server.incrementMemberCount();
        User user = new UserImpl(api, packet.get("user"), member, server);
        ServerMemberJoinEvent event = new ServerMemberJoinEventImpl(server, user);
        api.getEventDispatcher().dispatchServerMemberJoinEvent(server, server, user, event);
    });
}
Also used : ServerImpl(org.javacord.core.entity.server.ServerImpl) ServerMemberJoinEventImpl(org.javacord.core.event.server.member.ServerMemberJoinEventImpl) ServerMemberJoinEvent(org.javacord.api.event.server.member.ServerMemberJoinEvent) User(org.javacord.api.entity.user.User) PacketHandler(org.javacord.core.util.gateway.PacketHandler) DiscordApi(org.javacord.api.DiscordApi) UserImpl(org.javacord.core.entity.user.UserImpl) MemberImpl(org.javacord.core.entity.user.MemberImpl) JsonNode(com.fasterxml.jackson.databind.JsonNode) ServerMemberJoinEvent(org.javacord.api.event.server.member.ServerMemberJoinEvent) User(org.javacord.api.entity.user.User) ServerImpl(org.javacord.core.entity.server.ServerImpl) ServerMemberJoinEventImpl(org.javacord.core.event.server.member.ServerMemberJoinEventImpl) MemberImpl(org.javacord.core.entity.user.MemberImpl) UserImpl(org.javacord.core.entity.user.UserImpl)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 DiscordApi (org.javacord.api.DiscordApi)1 User (org.javacord.api.entity.user.User)1 ServerMemberJoinEvent (org.javacord.api.event.server.member.ServerMemberJoinEvent)1 ServerImpl (org.javacord.core.entity.server.ServerImpl)1 MemberImpl (org.javacord.core.entity.user.MemberImpl)1 UserImpl (org.javacord.core.entity.user.UserImpl)1 ServerMemberJoinEventImpl (org.javacord.core.event.server.member.ServerMemberJoinEventImpl)1 PacketHandler (org.javacord.core.util.gateway.PacketHandler)1