use of net.dv8tion.jda.api.exceptions.MissingAccessException in project JDA by DV8FromTheWorld.
the class NewsChannel method follow.
/**
* Subscribes to the crossposted messages in this channel.
* <br>This will create a {@link Webhook} of type {@link WebhookType#FOLLOWER FOLLOWER} in the target channel.
*
* <p>Possible {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} include:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>If the target channel doesn't exist or not visible to the currently logged in account</li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>If the currently logged in account does not have {@link Permission#MANAGE_WEBHOOKS} in the <b>target channel</b></li>
*
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MAX_WEBHOOKS MAX_WEBHOOKS}
* <br>If the target channel already has reached the maximum capacity for webhooks</li>
* </ul>
*
* @param targetChannel
* The target channel
*
* @throws InsufficientPermissionException
* If the currently logged in account does not have {@link Permission#MANAGE_WEBHOOKS} in the <b>target channel</b>.
* @throws IllegalArgumentException
* If null is provided
*
* @return {@link RestAction}
*
* @since 4.2.1
*/
@Nonnull
@CheckReturnValue
default RestAction<Webhook.WebhookReference> follow(@Nonnull TextChannel targetChannel) {
Checks.notNull(targetChannel, "Target Channel");
Member selfMember = targetChannel.getGuild().getSelfMember();
if (!selfMember.hasAccess(targetChannel))
throw new MissingAccessException(targetChannel, Permission.VIEW_CHANNEL);
if (!selfMember.hasPermission(targetChannel, Permission.MANAGE_WEBHOOKS))
throw new InsufficientPermissionException(targetChannel, Permission.MANAGE_WEBHOOKS);
return follow(targetChannel.getId());
}
use of net.dv8tion.jda.api.exceptions.MissingAccessException in project JDA by DV8FromTheWorld.
the class PermOverrideManagerImpl method checkPermissions.
@Override
protected boolean checkPermissions() {
Member selfMember = getGuild().getSelfMember();
IPermissionContainer channel = getChannel();
if (!selfMember.hasPermission(channel, Permission.VIEW_CHANNEL))
throw new MissingAccessException(channel, Permission.VIEW_CHANNEL);
if (!selfMember.hasAccess(channel))
throw new MissingAccessException(channel, Permission.VOICE_CONNECT);
if (!selfMember.hasPermission(channel, Permission.MANAGE_PERMISSIONS))
throw new InsufficientPermissionException(channel, Permission.MANAGE_PERMISSIONS);
return super.checkPermissions();
}
use of net.dv8tion.jda.api.exceptions.MissingAccessException in project JDA by DV8FromTheWorld.
the class WebhookManagerImpl method checkPermissions.
@Override
protected boolean checkPermissions() {
Member selfMember = getGuild().getSelfMember();
BaseGuildMessageChannel channel = getChannel();
if (!selfMember.hasAccess(channel))
throw new MissingAccessException(channel, Permission.VIEW_CHANNEL);
if (!selfMember.hasPermission(channel, Permission.MANAGE_WEBHOOKS))
throw new InsufficientPermissionException(channel, Permission.MANAGE_WEBHOOKS);
return super.checkPermissions();
}
Aggregations