Search in sources :

Example 1 with RoleDeleteEvent

use of org.javacord.api.event.server.role.RoleDeleteEvent in project Javacord by BtoBastian.

the class GuildRoleDeleteHandler method handle.

@Override
public void handle(JsonNode packet) {
    long serverId = packet.get("guild_id").asLong();
    api.getPossiblyUnreadyServerById(serverId).map(server -> ((ServerImpl) server)).ifPresent(server -> {
        long roleId = packet.get("role_id").asLong();
        server.getRoleById(roleId).ifPresent(role -> {
            server.removeRole(roleId);
            RoleDeleteEvent event = new RoleDeleteEventImpl(role);
            api.getEventDispatcher().dispatchRoleDeleteEvent(server, role, server, event);
        });
    });
}
Also used : ServerImpl(org.javacord.core.entity.server.ServerImpl) RoleDeleteEventImpl(org.javacord.core.event.server.role.RoleDeleteEventImpl) RoleDeleteEvent(org.javacord.api.event.server.role.RoleDeleteEvent) PacketHandler(org.javacord.core.util.gateway.PacketHandler) DiscordApi(org.javacord.api.DiscordApi) JsonNode(com.fasterxml.jackson.databind.JsonNode) RoleDeleteEvent(org.javacord.api.event.server.role.RoleDeleteEvent) RoleDeleteEventImpl(org.javacord.core.event.server.role.RoleDeleteEventImpl)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 DiscordApi (org.javacord.api.DiscordApi)1 RoleDeleteEvent (org.javacord.api.event.server.role.RoleDeleteEvent)1 ServerImpl (org.javacord.core.entity.server.ServerImpl)1 RoleDeleteEventImpl (org.javacord.core.event.server.role.RoleDeleteEventImpl)1 PacketHandler (org.javacord.core.util.gateway.PacketHandler)1