Search in sources :

Example 1 with ServerChannelChangeOverwrittenPermissionsEvent

use of org.javacord.api.event.channel.server.ServerChannelChangeOverwrittenPermissionsEvent in project Javacord by BtoBastian.

the class ChannelUpdateHandler method dispatchServerChannelChangeOverwrittenPermissionsEvent.

/**
 * Dispatches a ServerChannelChangeOverwrittenPermissionsEvent.
 *
 * @param channel        The channel of the event.
 * @param newPermissions The new overwritten permissions.
 * @param oldPermissions The old overwritten permissions.
 * @param entityId       The id of the entity.
 * @param entity         The entity of the event.
 */
private void dispatchServerChannelChangeOverwrittenPermissionsEvent(ServerChannel channel, Permissions newPermissions, Permissions oldPermissions, long entityId, DiscordEntity entity) {
    if (newPermissions.equals(oldPermissions)) {
        // any of its values. We don't need to dispatch an event for this.
        return;
    }
    ServerChannelChangeOverwrittenPermissionsEvent event = new ServerChannelChangeOverwrittenPermissionsEventImpl(channel, newPermissions, oldPermissions, entityId, entity);
    api.getEventDispatcher().dispatchServerChannelChangeOverwrittenPermissionsEvent((DispatchQueueSelector) channel.getServer(), (entity instanceof Role) ? (Role) entity : null, channel.getServer(), channel, (entity instanceof User) ? (User) entity : null, event);
}
Also used : Role(org.javacord.api.entity.permission.Role) User(org.javacord.api.entity.user.User) ServerChannelChangeOverwrittenPermissionsEventImpl(org.javacord.core.event.channel.server.ServerChannelChangeOverwrittenPermissionsEventImpl) ServerChannelChangeOverwrittenPermissionsEvent(org.javacord.api.event.channel.server.ServerChannelChangeOverwrittenPermissionsEvent)

Aggregations

Role (org.javacord.api.entity.permission.Role)1 User (org.javacord.api.entity.user.User)1 ServerChannelChangeOverwrittenPermissionsEvent (org.javacord.api.event.channel.server.ServerChannelChangeOverwrittenPermissionsEvent)1 ServerChannelChangeOverwrittenPermissionsEventImpl (org.javacord.core.event.channel.server.ServerChannelChangeOverwrittenPermissionsEventImpl)1