SpeakingFlags

A collection of multiple SpeakingFlags.

Creating an instance of SpeakingFlags

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

// from individual SpeakingFlags
val speakingFlags1 = SpeakingFlags(SpeakingFlag.Microphone, SpeakingFlag.Soundshare)

// from an Iterable
val iterable: Iterable<SpeakingFlag> = TODO()
val speakingFlags2 = SpeakingFlags(iterable)

// using a builder
val speakingFlags3 = SpeakingFlags {
+speakingFlags2
+SpeakingFlag.Microphone
-SpeakingFlag.Soundshare
}

Modifying an existing instance of SpeakingFlags

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

speakingFlags.copy {
+SpeakingFlag.Microphone
}

Mathematical operators

All SpeakingFlags objects can use +/- operators:

val speakingFlags1 = speakingFlags + SpeakingFlag.Microphone
val speakingFlags2 = speakingFlags - SpeakingFlag.Soundshare
val speakingFlags3 = speakingFlags1 + speakingFlags2

Checking for SpeakingFlags

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

val hasSpeakingFlag = SpeakingFlag.Microphone in speakingFlags
val hasSpeakingFlags = SpeakingFlags(SpeakingFlag.Microphone, SpeakingFlag.Soundshare) in speakingFlags

Unknown SpeakingFlags

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

You can also use SpeakingFlag.fromShift to check for unknown SpeakingFlags.

val hasUnknownSpeakingFlag = SpeakingFlag.fromShift(23) in speakingFlags

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 SpeakingFlags contained in this instance of SpeakingFlags.

Functions

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

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

operator fun contains(flags: SpeakingFlags): Boolean

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

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

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

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

operator fun minus(flags: SpeakingFlags): SpeakingFlags

Returns an instance of SpeakingFlags 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: SpeakingFlag): SpeakingFlags

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

operator fun plus(flags: SpeakingFlags): SpeakingFlags

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

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