/** * Sets the {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} of the selected {@link net.dv8tion.jda.core.entities.Webhook Webhook}. * * <p>A webhook channel <b>must not</b> be {@code null} and <b>must</b> be in the same {@link net.dv8tion.jda.core.entities.Guild Guild}! * * @param channel * The new {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} * for the selected {@link net.dv8tion.jda.core.entities.Webhook Webhook} * * @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException * If the currently logged in account does not have the Permission {@link net.dv8tion.jda.core.Permission#MANAGE_WEBHOOKS MANAGE_WEBHOOKS} * in the specified TextChannel * @throws IllegalArgumentException * If the provided channel is {@code null} or from a different Guild * * @return WebhookManager for chaining convenience */ @CheckReturnValue public WebhookManager setChannel(TextChannel channel) { Checks.notNull(channel, "Channel"); Checks.check(channel.getGuild().equals(getGuild()), "Channel is not from the same guild"); this.channel = channel.getId(); set |= CHANNEL; return this; }
@Override protected boolean checkPermissions() { if (!getGuild().getSelfMember().hasPermission(getChannel(), Permission.MANAGE_WEBHOOKS)) throw new InsufficientPermissionException(Permission.MANAGE_WEBHOOKS); return super.checkPermissions(); } }