Search in sources :

Example 1 with ServerMemberBanEventImpl

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

the class GuildBanAddHandler 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());
        ServerMemberBanEvent event = new ServerMemberBanEventImpl(server, user);
        api.getEventDispatcher().dispatchServerMemberBanEvent(server, server, user, event);
    });
}
Also used : ServerImpl(org.javacord.core.entity.server.ServerImpl) ServerMemberBanEvent(org.javacord.api.event.server.member.ServerMemberBanEvent) 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) ServerMemberBanEventImpl(org.javacord.core.event.server.member.ServerMemberBanEventImpl) MemberImpl(org.javacord.core.entity.user.MemberImpl) JsonNode(com.fasterxml.jackson.databind.JsonNode) User(org.javacord.api.entity.user.User) ServerImpl(org.javacord.core.entity.server.ServerImpl) UserImpl(org.javacord.core.entity.user.UserImpl) ServerMemberBanEvent(org.javacord.api.event.server.member.ServerMemberBanEvent) ServerMemberBanEventImpl(org.javacord.core.event.server.member.ServerMemberBanEventImpl)

Aggregations

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