Search in sources :

Example 1 with ServerMemberLeaveEvent

use of org.javacord.api.event.server.member.ServerMemberLeaveEvent in project Javacord by BtoBastian.

the class GuildMemberRemoveHandler method handle.

@Override
public void handle(JsonNode packet) {
    api.getPossiblyUnreadyServerById(packet.get("guild_id").asLong()).map(server -> (ServerImpl) server).ifPresent(server -> {
        User user = new UserImpl(api, packet.get("user"), (MemberImpl) null, server);
        server.removeMember(user.getId());
        server.decrementMemberCount();
        ServerMemberLeaveEvent event = new ServerMemberLeaveEventImpl(server, user);
        api.getEventDispatcher().dispatchServerMemberLeaveEvent(server, server, user, event);
    });
}
Also used : ServerImpl(org.javacord.core.entity.server.ServerImpl) User(org.javacord.api.entity.user.User) ServerMemberLeaveEvent(org.javacord.api.event.server.member.ServerMemberLeaveEvent) 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) ServerMemberLeaveEventImpl(org.javacord.core.event.server.member.ServerMemberLeaveEventImpl) JsonNode(com.fasterxml.jackson.databind.JsonNode) User(org.javacord.api.entity.user.User) ServerMemberLeaveEvent(org.javacord.api.event.server.member.ServerMemberLeaveEvent) ServerImpl(org.javacord.core.entity.server.ServerImpl) UserImpl(org.javacord.core.entity.user.UserImpl) ServerMemberLeaveEventImpl(org.javacord.core.event.server.member.ServerMemberLeaveEventImpl)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 DiscordApi (org.javacord.api.DiscordApi)1 User (org.javacord.api.entity.user.User)1 ServerMemberLeaveEvent (org.javacord.api.event.server.member.ServerMemberLeaveEvent)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 ServerMemberLeaveEventImpl (org.javacord.core.event.server.member.ServerMemberLeaveEventImpl)1 PacketHandler (org.javacord.core.util.gateway.PacketHandler)1