Java Code Examples for net.dv8tion.jda.api.Permission#getPermissions()
The following examples show how to use
net.dv8tion.jda.api.Permission#getPermissions() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AudioManagerImpl.java From JDA with Apache License 2.0 | 6 votes |
private void checkChannel(VoiceChannel channel, Member self) { EnumSet<Permission> perms = Permission.getPermissions(PermissionUtil.getEffectivePermission(channel, self)); if (!perms.contains(Permission.VOICE_CONNECT)) throw new InsufficientPermissionException(channel, Permission.VOICE_CONNECT); final int userLimit = channel.getUserLimit(); // userLimit is 0 if no limit is set! if (userLimit > 0 && !perms.contains(Permission.ADMINISTRATOR)) { // Check if we can actually join this channel // - If there is a userlimit // - If that userlimit is reached // - If we don't have voice move others permissions // VOICE_MOVE_OTHERS allows access because you would be able to move people out to // open up a slot anyway if (userLimit <= channel.getMembers().size() && !perms.contains(Permission.VOICE_MOVE_OTHERS)) { throw new InsufficientPermissionException(channel, Permission.VOICE_MOVE_OTHERS, "Unable to connect to VoiceChannel due to userlimit! Requires permission VOICE_MOVE_OTHERS to bypass"); } } }
Example 2
Source File: RoleManagerImpl.java From JDA with Apache License 2.0 | 6 votes |
@Nonnull @Override @CheckReturnValue public RoleManagerImpl setPermissions(long perms) { long selfPermissions = PermissionUtil.getEffectivePermission(getGuild().getSelfMember()); setupPermissions(); long missingPerms = perms; // include permissions we want to set to missingPerms &= ~selfPermissions; // exclude permissions we have missingPerms &= ~this.permissions; // exclude permissions the role has // if any permissions remain, we have an issue if (missingPerms != 0 && isPermissionChecksEnabled()) { EnumSet<Permission> permissionList = Permission.getPermissions(missingPerms); if (!permissionList.isEmpty()) throw new InsufficientPermissionException(getGuild(), permissionList.iterator().next()); } this.permissions = perms; set |= PERMISSION; return this; }
Example 3
Source File: RoleActionImpl.java From JDA with Apache License 2.0 | 5 votes |
@Nonnull @Override @CheckReturnValue public RoleActionImpl setPermissions(Long permissions) { if (permissions != null) { Checks.notNegative(permissions, "Raw Permissions"); Checks.check(permissions <= Permission.ALL_PERMISSIONS, "Provided permissions may not be greater than a full permission set!"); for (Permission p : Permission.getPermissions(permissions)) checkPermission(p); } this.permissions = permissions; return this; }
Example 4
Source File: DiscordGuildDetails.java From JuniperBot with GNU General Public License v3.0 | 5 votes |
public static DiscordGuildDetails create(Map<Object, Object> map) { DiscordGuildDetails details = new DiscordGuildDetails(); setValue(String.class, map, "id", details::setId); setValue(String.class, map, "name", details::setName); setValue(String.class, map, "icon", details::setIcon); setValue(Boolean.class, map, "owner", details::setOwner); Object permissions = map.get("permissions"); if (permissions instanceof Number) { details.permissions = Permission.getPermissions(((Number) permissions).longValue()); } return details; }
Example 5
Source File: MemberImpl.java From JDA with Apache License 2.0 | 5 votes |
@Nonnull @Override public EnumSet<Permission> getPermissions(@Nonnull GuildChannel channel) { Checks.notNull(channel, "Channel"); if (!getGuild().equals(channel.getGuild())) throw new IllegalArgumentException("Provided channel is not in the same guild as this member!"); return Permission.getPermissions(PermissionUtil.getEffectivePermission(channel, this)); }
Example 6
Source File: MemberImpl.java From JDA with Apache License 2.0 | 4 votes |
@Nonnull @Override public EnumSet<Permission> getPermissions() { return Permission.getPermissions(PermissionUtil.getEffectivePermission(this)); }
Example 7
Source File: RoleImpl.java From JDA with Apache License 2.0 | 4 votes |
@Nonnull @Override public EnumSet<Permission> getPermissionsExplicit(@Nonnull GuildChannel channel) { return Permission.getPermissions(PermissionUtil.getExplicitPermission(channel, this)); }
Example 8
Source File: RoleImpl.java From JDA with Apache License 2.0 | 4 votes |
@Nonnull @Override public EnumSet<Permission> getPermissions(@Nonnull GuildChannel channel) { return Permission.getPermissions(PermissionUtil.getEffectivePermission(channel, this)); }
Example 9
Source File: RoleImpl.java From JDA with Apache License 2.0 | 4 votes |
@Nonnull @Override public EnumSet<Permission> getPermissions() { return Permission.getPermissions(rawPermissions); }
Example 10
Source File: PermissionOverrideImpl.java From JDA with Apache License 2.0 | 4 votes |
@Nonnull @Override public EnumSet<Permission> getInherit() { return Permission.getPermissions(getInheritRaw()); }
Example 11
Source File: PermissionOverrideImpl.java From JDA with Apache License 2.0 | 4 votes |
@Nonnull @Override public EnumSet<Permission> getAllowed() { return Permission.getPermissions(allow); }
Example 12
Source File: MemberImpl.java From JDA with Apache License 2.0 | 4 votes |
@Nonnull @Override public EnumSet<Permission> getPermissionsExplicit(@Nonnull GuildChannel channel) { return Permission.getPermissions(PermissionUtil.getExplicitPermission(channel, this)); }
Example 13
Source File: MemberImpl.java From JDA with Apache License 2.0 | 4 votes |
@Nonnull @Override public EnumSet<Permission> getPermissionsExplicit() { return Permission.getPermissions(PermissionUtil.getExplicitPermission(this)); }
Example 14
Source File: PermissionOverrideUpdateEvent.java From JDA with Apache License 2.0 | 4 votes |
/** * The old inherited permissions * * @return The old inherited permissions */ @Nonnull public EnumSet<Permission> getOldInherited() { return Permission.getPermissions(getOldInheritedRaw()); }
Example 15
Source File: PermissionOverrideUpdateEvent.java From JDA with Apache License 2.0 | 4 votes |
/** * The old denied permissions * * @return The old denied permissions */ @Nonnull public EnumSet<Permission> getOldDeny() { return Permission.getPermissions(oldDeny); }
Example 16
Source File: PermissionOverrideUpdateEvent.java From JDA with Apache License 2.0 | 4 votes |
/** * The old allowed permissions * * @return The old allowed permissions */ @Nonnull public EnumSet<Permission> getOldAllow() { return Permission.getPermissions(oldAllow); }
Example 17
Source File: RoleUpdatePermissionsEvent.java From JDA with Apache License 2.0 | 4 votes |
public RoleUpdatePermissionsEvent(@Nonnull JDA api, long responseNumber, @Nonnull Role role, long oldPermissionsRaw) { super(api, responseNumber, role, Permission.getPermissions(oldPermissionsRaw), role.getPermissions(), IDENTIFIER); this.oldPermissionsRaw = oldPermissionsRaw; this.newPermissionsRaw = role.getPermissionsRaw(); }
Example 18
Source File: PermissionOverrideAction.java From JDA with Apache License 2.0 | 2 votes |
/** * Set of {@link net.dv8tion.jda.api.Permission Permissions} * that would be <b>inherited</b> from other permission holders. * <br>Permissions returned are not explicitly granted or denied! * <br><u>Changes to the returned set do not affect this entity directly.</u> * * @return set of inherited {@link net.dv8tion.jda.api.Permission Permissions} * * @see #getInherited() */ @Nonnull default EnumSet<Permission> getInheritedPermissions() { return Permission.getPermissions(getInherited()); }
Example 19
Source File: PermissionOverrideAction.java From JDA with Apache License 2.0 | 2 votes |
/** * Set of {@link net.dv8tion.jda.api.Permission Permissions} * that would be <b>denied</b> by the PermissionOverride that is created by this action. * <br><u>Changes to the returned set do not affect this entity directly.</u> * * @return set of denied {@link net.dv8tion.jda.api.Permission Permissions} */ @Nonnull default EnumSet<Permission> getDeniedPermissions() { return Permission.getPermissions(getDeny()); }
Example 20
Source File: PermissionOverrideAction.java From JDA with Apache License 2.0 | 2 votes |
/** * Set of {@link net.dv8tion.jda.api.Permission Permissions} * that would be <b>granted</b> by the PermissionOverride that is created by this action. * <br><u>Changes to the returned set do not affect this entity directly.</u> * * @return set of granted {@link net.dv8tion.jda.api.Permission Permissions} */ @Nonnull default EnumSet<Permission> getAllowedPermissions() { return Permission.getPermissions(getAllow()); }