@Override public String getInviteUrl(Permission... permissions) { StringBuilder builder = buildBaseInviteUrl(); if (permissions != null && permissions.length > 0) builder.append("&permissions=").append(Permission.getRaw(permissions)); return builder.toString(); }
@Override public String getInviteUrl(Collection<Permission> permissions) { StringBuilder builder = buildBaseInviteUrl(); if (permissions != null && !permissions.isEmpty()) builder.append("&permissions=").append(Permission.getRaw(permissions)); return builder.toString(); }
/** * This is effectively the opposite of {@link #getPermissions(long)}, this takes a Collection of {@link net.dv8tion.jda.core.Permission Permissions} * and returns the raw offset {@code long} representation of the permissions. * <br>Example: {@code getRaw(EnumSet.of(Permission.MESSAGE_READ, Permission.MESSAGE_WRITE))} * * @param permissions * The Collection of permissions of which to form into the raw long representation. * * @return Unsigned long representing the provided permissions. * * @see java.util.EnumSet EnumSet */ public static long getRaw(Collection<Permission> permissions) { Checks.notNull(permissions, "Permission Collection"); return getRaw(permissions.toArray(EMPTY_PERMISSIONS)); } }
@Override public String getInviteUrl(final String guildId, final Collection<Permission> permissions) { StringBuilder builder = new StringBuilder("https://discordapp.com/oauth2/authorize?client_id="); builder.append(this.getId()); builder.append("&scope=bot"); if (permissions != null && !permissions.isEmpty()) { builder.append("&permissions="); builder.append(Permission.getRaw(permissions)); } if (guildId != null) { builder.append("&guild_id="); builder.append(guildId); } return builder.toString(); }
@Override public String getInviteUrl(final String guildId, final Collection<Permission> permissions) { StringBuilder builder = new StringBuilder("https://discordapp.com/oauth2/authorize?client_id="); builder.append(this.getId()); builder.append("&scope=bot"); if (permissions != null && !permissions.isEmpty()) { builder.append("&permissions="); builder.append(Permission.getRaw(permissions)); } if (guildId != null) { builder.append("&guild_id="); builder.append(guildId); } return builder.toString(); }
/** * Adds the provided permissions to the Role * * @param permissions * The permissions to add * * @throws java.lang.IllegalArgumentException * If any of the provided permissions is {@code null} * * @return The current RoleData instance for chaining convenience */ public RoleData addPermissions(Collection<Permission> permissions) { Checks.noneNull(permissions, "Permissions"); if (this.permissions == null) this.permissions = 0L; this.permissions |= Permission.getRaw(permissions); return this; }
/** * Grants the provided {@link net.dv8tion.jda.core.Permission Permissions} * to the selected {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride}. * * @param permissions * The permissions to grant to the selected {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride} * * @throws IllegalArgumentException * If any of the provided Permissions is {@code null} * * @return PermOverrideManager for chaining convenience * * @see java.util.EnumSet EnumSet * @see net.dv8tion.jda.core.Permission#getRaw(java.util.Collection) Permission.getRaw(Collection) */ @CheckReturnValue public PermOverrideManager grant(Collection<Permission> permissions) { return grant(Permission.getRaw(permissions)); }
/** * Denies the provided {@link net.dv8tion.jda.core.Permission Permissions} * from the selected {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride}. * * @param permissions * The permissions to deny from the selected {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride} * * @throws IllegalArgumentException * If any of the provided Permissions is {@code null} * * @return PermOverrideManager for chaining convenience * * @see java.util.EnumSet EnumSet * @see net.dv8tion.jda.core.Permission#getRaw(java.util.Collection) Permission.getRaw(Collection) */ @CheckReturnValue public PermOverrideManager deny(Collection<Permission> permissions) { return deny(Permission.getRaw(permissions)); }
/** * Clears the provided {@link net.dv8tion.jda.core.Permission Permissions} bits * from the selected {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride}. * <br>This will cause the provided Permissions to be inherited * * @param permissions * The permissions to clear from the selected {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride} * * @throws IllegalArgumentException * If any of the provided Permissions is {@code null} * * @return PermOverrideManager for chaining convenience * * @see java.util.EnumSet EnumSet * @see net.dv8tion.jda.core.Permission#getRaw(java.util.Collection) Permission.getRaw(Collection) */ @CheckReturnValue public PermOverrideManager clear(Collection<Permission> permissions) { return clear(Permission.getRaw(permissions)); }
/** * Grants the provided {@link net.dv8tion.jda.core.Permission Permissions} * to the selected {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride}. * * @param permissions * The permissions to grant to the selected {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride} * * @throws IllegalArgumentException * If any of the provided Permissions is {@code null} * * @return PermOverrideManager for chaining convenience * * @see net.dv8tion.jda.core.Permission#getRaw(net.dv8tion.jda.core.Permission...) Permission.getRaw(Permission...) */ @CheckReturnValue public PermOverrideManager grant(Permission... permissions) { Checks.notNull(permissions, "Permissions"); return grant(Permission.getRaw(permissions)); }
/** * Clears the provided {@link net.dv8tion.jda.core.Permission Permissions} bits * from the selected {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride}. * <br>This will cause the provided Permissions to be inherited * * @param permissions * The permissions to clear from the selected {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride} * * @throws IllegalArgumentException * If any of the provided Permissions is {@code null} * * @return PermOverrideManager for chaining convenience */ @CheckReturnValue public PermOverrideManager clear(Permission... permissions) { Checks.notNull(permissions, "Permissions"); return clear(Permission.getRaw(permissions)); }
/** * Denies the provided {@link net.dv8tion.jda.core.Permission Permissions} * from the selected {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride}. * * @param permissions * The permissions to deny from the selected {@link net.dv8tion.jda.core.entities.PermissionOverride PermissionOverride} * * @throws IllegalArgumentException * If any of the provided Permissions is {@code null} * * @return PermOverrideManager for chaining convenience * * @see net.dv8tion.jda.core.Permission#getRaw(net.dv8tion.jda.core.Permission...) Permission.getRaw(Permission...) */ @CheckReturnValue public PermOverrideManager deny(Permission... permissions) { Checks.notNull(permissions, "Permissions"); return deny(Permission.getRaw(permissions)); }
/** * Adds the provided permissions to the Role * * @param permissions * The permissions to add * * @throws java.lang.IllegalArgumentException * If any of the provided permissions is {@code null} * * @return The current RoleData instance for chaining convenience */ public RoleData addPermissions(Permission... permissions) { Checks.notNull(permissions, "Permissions"); for (Permission perm : permissions) Checks.notNull(perm, "Permissions"); if (this.permissions == null) this.permissions = 0L; this.permissions |= Permission.getRaw(permissions); return this; }
/** * Sets the {@link net.dv8tion.jda.core.Permission Permissions} of the selected {@link net.dv8tion.jda.core.entities.Role Role}. * * <p>Permissions may only include already present Permissions for the currently logged in account. * <br>You are unable to give permissions you don't have! * * @param permissions * The new permission for the selected {@link net.dv8tion.jda.core.entities.Role Role} * * @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException * If the currently logged in account does not have permission to apply one of the specified permissions * @throws java.lang.IllegalArgumentException * If any of the provided values is {@code null} * * @return RoleManager for chaining convenience * * @see #setPermissions(Permission...) * @see #setPermissions(long) * @see java.util.EnumSet EnumSet * @see net.dv8tion.jda.core.Permission#getRaw(java.util.Collection) Permission.getRaw(Collection) */ @CheckReturnValue public RoleManager setPermissions(Collection<Permission> permissions) { Checks.noneNull(permissions, "Permissions"); return setPermissions(Permission.getRaw(permissions)); }
/** * Sets the value of explicitly denied permissions * using a Collection of {@link net.dv8tion.jda.core.Permission Permissions}. * <br><b>Note: Permissions not marked as {@link net.dv8tion.jda.core.Permission#isChannel() isChannel()} will have no affect!</b> * * <p>Example: {@code setDeny(EnumSet.of(Permission.MESSAGE_WRITE, Permission.MESSAGE_EXT_EMOJI))}</p> * * @param permissions * The Collection of Permissions representing the denied * permissions for the new PermissionOverride. * <br>If the provided value is {@code null} the permissions are reset to the default of none * * @throws java.lang.IllegalArgumentException * If the any of the specified Permissions is {@code null} * * @return The current PermissionOverrideAction - for chaining convenience * * @see java.util.EnumSet EnumSet * @see #setDeny(net.dv8tion.jda.core.Permission...) setDeny(Permission...) */ @CheckReturnValue public PermissionOverrideAction setDeny(Collection<Permission> permissions) { if (permissions == null || permissions.isEmpty()) return setDeny(0); checkNull(permissions, "Permission"); return setDeny(Permission.getRaw(permissions)); }
/** * Sets the value of explicitly granted permissions * using a Collection of {@link net.dv8tion.jda.core.Permission Permissions}. * <br><b>Note: Permissions not marked as {@link net.dv8tion.jda.core.Permission#isChannel() isChannel()} will have no affect!</b> * * <p>Example: {@code setAllow(EnumSet.of(Permission.MESSAGE_READ))}</p> * * @param permissions * The Collection of Permissions representing the granted * permissions for the new PermissionOverride. * <br>If the provided value is {@code null} the permissions are reset to the default of none * * @throws java.lang.IllegalArgumentException * If the any of the specified Permissions is {@code null} * * @return The current PermissionOverrideAction - for chaining convenience * * @see java.util.EnumSet EnumSet * @see #setAllow(net.dv8tion.jda.core.Permission...) setAllow(Permission...) */ @CheckReturnValue public PermissionOverrideAction setAllow(Collection<Permission> permissions) { if (permissions == null || permissions.isEmpty()) return setAllow(0); checkNull(permissions, "Permission"); return setAllow(Permission.getRaw(permissions)); }
/** * Sets the value of explicitly granted permissions * using a set of {@link net.dv8tion.jda.core.Permission Permissions}. * <br><b>Note: Permissions not marked as {@link net.dv8tion.jda.core.Permission#isChannel() isChannel()} will have no affect!</b> * * @param permissions * The Permissions representing the granted * permissions for the new PermissionOverride. * <br>If the provided value is {@code null} the permissions are reset to the default of none * * @throws java.lang.IllegalArgumentException * If the any of the specified Permissions is {@code null} * * @return The current PermissionOverrideAction - for chaining convenience */ @CheckReturnValue public PermissionOverrideAction setAllow(Permission... permissions) { if (permissions == null || permissions.length < 1) return setAllow(0); checkNull(permissions, "Permission"); return setAllow(Permission.getRaw(permissions)); }
/** * Sets the value of explicitly denied permissions * using a set of {@link net.dv8tion.jda.core.Permission Permissions}. * <br><b>Note: Permissions not marked as {@link net.dv8tion.jda.core.Permission#isChannel() isChannel()} will have no affect!</b> * * @param permissions * The Permissions representing the denied * permissions for the new PermissionOverride. * <br>If the provided value is {@code null} the permissions are reset to the default of none * * @throws java.lang.IllegalArgumentException * If the any of the specified Permissions is {@code null} * * @return The current PermissionOverrideAction - for chaining convenience */ @CheckReturnValue public PermissionOverrideAction setDeny(Permission... permissions) { if (permissions == null || permissions.length < 1) return setDeny(0); checkNull(permissions, "Permission"); return setDeny(Permission.getRaw(permissions)); }
/** * Revokes the specified {@link net.dv8tion.jda.core.Permission Permissions} from the selected {@link net.dv8tion.jda.core.entities.Role Role}. * * <p>Permissions may only include already present Permissions for the currently logged in account. * <br>You are unable to revoke permissions you don't have! * * @param perms * The permission to give to the selected {@link net.dv8tion.jda.core.entities.Role Role} * * @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException * If the currently logged in account does not have permission to revoke one of the specified permissions * * @return RoleManager for chaining convenience * * @see #setPermissions(Collection) * @see #setPermissions(Permission...) * @see java.util.EnumSet EnumSet * @see net.dv8tion.jda.core.Permission#getRaw(java.util.Collection) Permission.getRaw(Collection) */ @CheckReturnValue public RoleManager revokePermissions(Collection<Permission> perms) { Checks.noneNull(perms, "Permissions"); setupPermissions(); return setPermissions(this.permissions & ~Permission.getRaw(perms)); }
/** * Adds the specified {@link net.dv8tion.jda.core.Permission Permissions} to the selected {@link net.dv8tion.jda.core.entities.Role Role}. * * <p>Permissions may only include already present Permissions for the currently logged in account. * <br>You are unable to give permissions you don't have! * * @param perms * The permission to give to the selected {@link net.dv8tion.jda.core.entities.Role Role} * * @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException * If the currently logged in account does not have permission to apply one of the specified permissions * * @return RoleManager for chaining convenience * * @see #setPermissions(Collection) * @see #setPermissions(Permission...) * @see java.util.EnumSet EnumSet * @see net.dv8tion.jda.core.Permission#getRaw(java.util.Collection) Permission.getRaw(Collection) */ @CheckReturnValue public RoleManager givePermissions(Collection<Permission> perms) { Checks.noneNull(perms, "Permissions"); setupPermissions(); return setPermissions(this.permissions | Permission.getRaw(perms)); }