/** * Syncs all {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverrides} of this Channel with * its parent ({@link net.dv8tion.jda.core.entities.Category Category}). * * <p>After this operation, all {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverrides} * will be exactly the same as the ones from the parent. * <br><b>That means that all current PermissionOverrides are lost!</b> * * <p>This behaves as if calling {@link #sync(Channel)} with this Channel's {@link net.dv8tion.jda.core.entities.Channel#getParent() Parent}. * * @throws java.lang.IllegalStateException * If this Channel has no parent * @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException * If the currently logged in account does not have {@link net.dv8tion.jda.core.Permission#MANAGE_PERMISSIONS Permission.MANAGE_PERMISSIONS} * in this channel * * @return ChannelManager for chaining convenience * * @see <a href="https://discordapp.com/developers/docs/topics/permissions#permission-syncing" target="_blank">Discord Documentation - Permission Syncing</a> */ @CheckReturnValue public ChannelManager sync() { if(getChannel().getParent() == null) throw new IllegalStateException("sync() requires a parent category"); return sync(getChannel().getParent()); }
@Override protected void validateInput(T entity) { Checks.notNull(entity, "Provided channel"); Checks.check(getCategory().equals(entity.getParent()), "Provided channel's Category is not this Category!"); Checks.check(orderList.contains(entity), "Provided channel is not in the list of orderable channels!"); }
private void handleChannelCreate(GuildWrapper wrapper, Channel channel) { if (cannotHandle(wrapper, ModlogEvent.CHANNEL_CREATE)) return; AuditLogEntry entry = wrapper.getGuild().getAuditLogs().complete().get(0); EmbedBuilder builder = new EmbedBuilder() .addField("Type", channel.getType().name().toLowerCase(), true) .addField("Name", channel.getName(), true); if (channel.getParent() != null) { builder.addField("Category", channel.getParent().getName(), true); } ModlogHandler.getInstance().postToModlog(wrapper, ModlogEvent.CHANNEL_CREATE, entry.getUser(), builder); }
private void handleChannelDelete(GuildWrapper wrapper, Channel channel) { if (wrapper == null) return; if (cannotHandle(wrapper, ModlogEvent.CHANNEL_DELETE)) return; AuditLogEntry entry = wrapper.getGuild().getAuditLogs().complete().get(0); EmbedBuilder builder = new EmbedBuilder() .addField("Type", channel.getType().name().toLowerCase(), true) .addField("Name", channel.getName(), true); if (channel.getParent() != null) { builder.addField("Category", channel.getParent().getName(), true); } ModlogHandler.getInstance().postToModlog(wrapper, ModlogEvent.CHANNEL_DELETE, entry.getUser(), builder); }