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)
}

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
}

Mathematical operators

All RoleFlags objects can use +/- operators:

val roleFlags1 = roleFlags + RoleFlag.InPrompt
val roleFlags2 = roleFlags - RoleFlag.fromShift(22)
val roleFlags3 = roleFlags1 + roleFlags2

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

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

See also

Types

Link copied to clipboard
class Builder(value: Int = 0)

Properties

Link copied to clipboard
val value: Int

The raw value used by Discord.

Link copied to clipboard

A Set of all RoleFlags contained in this instance of RoleFlags.

Functions

Link copied to clipboard
operator fun contains(flag: RoleFlag): Boolean

Checks if this instance of RoleFlags has all bits set that are set in flag.

operator fun contains(flags: RoleFlags): Boolean

Checks if this instance of RoleFlags has all bits set that are set in flags.

Link copied to clipboard
inline fun copy(builder: RoleFlags.Builder.() -> Unit): RoleFlags

Returns a copy of this instance of RoleFlags modified with builder.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
operator fun minus(flag: RoleFlag): RoleFlags

Returns an instance of RoleFlags that has all bits set that are set in this except the bits that are set in flag.

operator fun minus(flags: RoleFlags): RoleFlags

Returns an instance of RoleFlags that has all bits set that are set in this except the bits that are set in flags.

Link copied to clipboard
operator fun plus(flag: RoleFlag): RoleFlags

Returns an instance of RoleFlags that has all bits set that are set in this and flag.

operator fun plus(flags: RoleFlags): RoleFlags

Returns an instance of RoleFlags that has all bits set that are set in this and flags.

Link copied to clipboard
open override fun toString(): String