public class PermissionUtil
extends java.lang.Object
Constructor and Description |
---|
PermissionUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkPermission(User user,
Permission perm,
Channel channel)
|
static boolean |
checkPermission(User user,
Permission perm,
Guild guild)
|
static int |
getEffectivePermission(User user,
Channel channel)
|
static PermissionOverride |
getFullPermOverride() |
public static PermissionOverride getFullPermOverride()
public static boolean checkPermission(User user, Permission perm, Channel channel)
User
has the specified Permission
in the specified Channel
. This method properly deals with
PermissionOverrides
and Owner status.
Note: this is based on effective permissions, not literal permissions. If a user has permissions that would
enable them to do something without the literal permission to do it, this will still return true.
Example: If a user has the Permission.MANAGE_ROLES
permission, they will be able to
Permission.MESSAGE_WRITE
in every channel.
user
- The User
whose permissions are being checked.perm
- The Permission
being checked for.channel
- The Channel
being checked.User
effectively has the specified Permission
.public static boolean checkPermission(User user, Permission perm, Guild guild)
User
has the specified Permission
in the specified Guild
. This method properly deals with Owner status.
Note: this is based on effective permissions, not literal permissions. If a user has permissions that would
enable them to do something without the literal permission to do it, this will still return true.
Example: If a user has the Permission.MANAGE_ROLES
permission, they will be able to
Permission.MANAGE_SERVER
as well, even without the literal permission.
user
- The User
whose permissions are being checked.perm
- The Permission
being checked for.guild
- The Guild
being checked.User
effectively has the specified Permission
.public static int getEffectivePermission(User user, Channel channel)
int
representation of the effective permissions allowed for this User
in this Channel
. This can be used in conjunction with
Permission.getPermissions(int)
to easily get a list of all
Permissions
that this user can use in this Channel
.Role.getPermissionsRaw()
.