UserFlags

A collection of multiple UserFlags.

Creating an instance of UserFlags

You can create an instance of UserFlags using the following methods:

// from individual UserFlags
val userFlags1 = UserFlags(UserFlag.DiscordEmployee, UserFlag.DiscordPartner)

// from an Iterable
val iterable: Iterable<UserFlag> = TODO()
val userFlags2 = UserFlags(iterable)

// using a builder
val userFlags3 = UserFlags {
+userFlags2
+UserFlag.DiscordEmployee
-UserFlag.DiscordPartner
}

Modifying an existing instance of UserFlags

You can create a modified copy of an existing instance of UserFlags using the copy method:

userFlags.copy {
+UserFlag.DiscordEmployee
}

Mathematical operators

All UserFlags objects can use +/- operators:

val userFlags1 = userFlags + UserFlag.DiscordEmployee
val userFlags2 = userFlags - UserFlag.DiscordPartner
val userFlags3 = userFlags1 + userFlags2

Checking for UserFlags

You can use the contains operator to check whether an instance of UserFlags contains specific UserFlags:

val hasUserFlag = UserFlag.DiscordEmployee in userFlags
val hasUserFlags = UserFlags(UserFlag.DiscordEmployee, UserFlag.DiscordPartner) in userFlags

Unknown UserFlags

Whenever UserFlags haven't been added to Kord yet, they will be deserialized as instances of UserFlag.Unknown.

You can also use UserFlag.fromShift to check for unknown UserFlags.

val hasUnknownUserFlag = UserFlag.fromShift(23) in userFlags

See also

Types

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

Properties

Link copied to clipboard
val code: Int

The raw code used by Discord.

Link copied to clipboard

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

Functions

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

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

operator fun contains(flags: UserFlags): Boolean

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

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

Returns a copy of this instance of UserFlags 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: UserFlag): UserFlags

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

operator fun minus(flags: UserFlags): UserFlags

Returns an instance of UserFlags 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: UserFlag): UserFlags

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

operator fun plus(flags: UserFlags): UserFlags

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

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