public class PermissionUtil
extends java.lang.Object
Constructor and Description |
---|
PermissionUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
canInteract(Member issuer,
Member target)
Checks if one given Member can interact with a 2nd given Member - in a permission sense (kick/ban/modify perms).
|
static boolean |
canInteract(Member issuer,
Role target)
Checks if a given Member can interact with a given Role - in a permission sense (kick/ban/modify perms).
|
static boolean |
canInteract(Role issuer,
Role target)
Checks if one given Role can interact with a 2nd given Role - in a permission sense (kick/ban/modify perms).
|
static boolean |
checkPermission(Channel channel,
Member member,
Permission... permissions)
|
static boolean |
checkPermission(Guild guild,
Member member,
Permission... permissions)
|
static long |
getEffectivePermission(Channel channel,
Member member)
|
static long |
getEffectivePermission(Guild guild,
Member member)
|
static PermissionOverride |
getFullPermOverride() |
public static boolean canInteract(Member issuer, Member target)
issuer
- The member that tries to interact with 2nd membertarget
- The member that is the target of the interactionpublic static boolean canInteract(Member issuer, Role target)
issuer
- The member that tries to interact with the roletarget
- The role that is the target of the interactionpublic static boolean canInteract(Role issuer, Role target)
issuer
- The role that tries to interact with 2nd roletarget
- The role that is the target of the interactionpublic static PermissionOverride getFullPermOverride()
public static boolean checkPermission(Guild guild, Member member, Permission... permissions)
Member
has the specified Permissions
in the specified Guild
. This method properly deals with Owner status.
Note: this is based on effective permissions, not literal permissions. If a member has permissions that would
enable them to do something without the literal permission to do it, this will still return true.
Example: If a member has the Permission.ADMINISTRATOR
permission, they will be able to
Permission.MANAGE_SERVER
as well, even without the literal permissions.
guild
- The Guild
being checked.member
- The Member
whose permissions are being checked.permissions
- The Permissions
being checked for.Member
effectively has the specified Permissions
.public static boolean checkPermission(Channel channel, Member member, Permission... permissions)
Member
has the specified Permissions
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 member has permissions that would
enable them to do something without the literal permission to do it, this will still return true.
Example: If a member has the Permission.ADMINISTRATOR
permission, they will be able to
Permission.MESSAGE_WRITE
in every channel.
member
- The Member
whose permissions are being checked.channel
- The Channel
being checked.permissions
- The Permissions
being checked for.Member
effectively has the specified Permissions
.public static long getEffectivePermission(Guild guild, Member member)
int
representation of the effective permissions allowed for this Member
in this Guild
. This can be used in conjunction with
Permission.getPermissions(int)
to easily get a list of all
Permissions
that this member has in this Guild
.
This only returns the Guild-level permissions!
public static long getEffectivePermission(Channel channel, Member member)
int
representation of the effective permissions allowed for this Member
in this Channel
. This can be used in conjunction with
Permission.getPermissions(int)
to easily get a list of all
Permissions
that this member can use in this Channel
.Role.getPermissionsRaw()
.