MessageFlags

A collection of multiple MessageFlags.

Creating an instance of MessageFlags

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

// from individual MessageFlags
val messageFlags1 = MessageFlags(MessageFlag.CrossPosted, MessageFlag.IsCrossPost)

// from an Iterable
val iterable: Iterable<MessageFlag> = TODO()
val messageFlags2 = MessageFlags(iterable)

// using a builder
val messageFlags3 = MessageFlags {
+messageFlags2
+MessageFlag.CrossPosted
-MessageFlag.IsCrossPost
}

Modifying an existing instance of MessageFlags

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

messageFlags.copy {
+MessageFlag.CrossPosted
}

Mathematical operators

All MessageFlags objects can use +/- operators:

val messageFlags1 = messageFlags + MessageFlag.CrossPosted
val messageFlags2 = messageFlags - MessageFlag.IsCrossPost
val messageFlags3 = messageFlags1 + messageFlags2

Checking for MessageFlags

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

val hasMessageFlag = MessageFlag.CrossPosted in messageFlags
val hasMessageFlags = MessageFlags(MessageFlag.CrossPosted, MessageFlag.IsCrossPost) in messageFlags

Unknown MessageFlags

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

You can also use MessageFlag.fromShift to check for unknown MessageFlags.

val hasUnknownMessageFlag = MessageFlag.fromShift(23) in messageFlags

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

Functions

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

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

operator fun contains(flags: MessageFlags): Boolean

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

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

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

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

operator fun minus(flags: MessageFlags): MessageFlags

Returns an instance of MessageFlags 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: MessageFlag): MessageFlags

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

operator fun plus(flags: MessageFlags): MessageFlags

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

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