RoleFlags
A collection of multiple RoleFlags.
Creating an instance of RoleFlags
You can create an instance of RoleFlags using the following methods:
// from individual RoleFlags
val roleFlags1 = RoleFlags(RoleFlag.InPrompt, RoleFlag.fromShift(22))
// from an Iterable
val iterable: Iterable<RoleFlag> = TODO()
val roleFlags2 = RoleFlags(iterable)
// using a builder
val roleFlags3 = RoleFlags {
+roleFlags2
+RoleFlag.InPrompt
-RoleFlag.fromShift(22)
}
Content copied to clipboard
Modifying an existing instance of RoleFlags
You can create a modified copy of an existing instance of RoleFlags using the copy method:
roleFlags.copy {
+RoleFlag.InPrompt
}
Content copied to clipboard
Mathematical operators
All RoleFlags objects can use +
/-
operators:
val roleFlags1 = roleFlags + RoleFlag.InPrompt
val roleFlags2 = roleFlags - RoleFlag.fromShift(22)
val roleFlags3 = roleFlags1 + roleFlags2
Content copied to clipboard
Checking for RoleFlags
You can use the contains operator to check whether an instance of RoleFlags contains specific RoleFlags:
val hasRoleFlag = RoleFlag.InPrompt in roleFlags
val hasRoleFlags = RoleFlags(RoleFlag.InPrompt, RoleFlag.fromShift(22)) in roleFlags
Content copied to clipboard
Unknown RoleFlags
Whenever RoleFlags haven't been added to Kord yet, they will be deserialized as instances of RoleFlag.Unknown.
You can also use RoleFlag.fromShift to check for unknown RoleFlags.
val hasUnknownRoleFlag = RoleFlag.fromShift(23) in roleFlags
Content copied to clipboard