Permissions
A collection of multiple Permissions.
Creating an instance of Permissions
You can create an instance of Permissions using the following methods:
// from individual Permissions
val permissions1 = Permissions(Permission.CreateInstantInvite, Permission.KickMembers)
// from an Iterable
val iterable: Iterable<Permission> = TODO()
val permissions2 = Permissions(iterable)
// using a builder
val permissions3 = Permissions {
+permissions2
+Permission.CreateInstantInvite
-Permission.KickMembers
}
Modifying an existing instance of Permissions
You can create a modified copy of an existing instance of Permissions using the copy method:
permissions.copy {
+Permission.CreateInstantInvite
}
Mathematical operators
All Permissions objects can use +
/-
operators:
val permissions1 = permissions + Permission.CreateInstantInvite
val permissions2 = permissions - Permission.KickMembers
val permissions3 = permissions1 + permissions2
Checking for Permissions
You can use the contains operator to check whether an instance of Permissions contains specific Permissions:
val hasPermission = Permission.CreateInstantInvite in permissions
val hasPermissions = Permissions(Permission.CreateInstantInvite, Permission.KickMembers) in permissions
Unknown Permissions
Whenever Permissions haven't been added to Kord yet, they will be deserialized as instances of Permission.Unknown.
You can also use Permission.fromShift to check for unknown Permissions.
val hasUnknownPermission = Permission.fromShift(23) in permissions
See also
Properties
The raw code used by Discord.
A Set of all Permissions contained in this instance of Permissions.
Functions
Checks if this instance of Permissions has all bits set that are set in flag.
Checks if this instance of Permissions has all bits set that are set in flags.
Returns a copy of this instance of Permissions modified with builder.
Returns an instance of Permissions that has all bits set that are set in this
except the bits that are set in flag.
Returns an instance of Permissions that has all bits set that are set in this
except the bits that are set in flags.
Returns an instance of Permissions that has all bits set that are set in this
and flag.
Returns an instance of Permissions that has all bits set that are set in this
and flags.