ChannelFlags

A collection of multiple ChannelFlags.

Creating an instance of ChannelFlags

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

// from individual ChannelFlags
val channelFlags1 = ChannelFlags(ChannelFlag.Pinned, ChannelFlag.RequireTag)

// from an Iterable
val iterable: Iterable<ChannelFlag> = TODO()
val channelFlags2 = ChannelFlags(iterable)

// using a builder
val channelFlags3 = ChannelFlags {
+channelFlags2
+ChannelFlag.Pinned
-ChannelFlag.RequireTag
}

Modifying an existing instance of ChannelFlags

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

channelFlags.copy {
+ChannelFlag.Pinned
}

Mathematical operators

All ChannelFlags objects can use +/- operators:

val channelFlags1 = channelFlags + ChannelFlag.Pinned
val channelFlags2 = channelFlags - ChannelFlag.RequireTag
val channelFlags3 = channelFlags1 + channelFlags2

Checking for ChannelFlags

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

val hasChannelFlag = ChannelFlag.Pinned in channelFlags
val hasChannelFlags = ChannelFlags(ChannelFlag.Pinned, ChannelFlag.RequireTag) in channelFlags

Unknown ChannelFlags

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

You can also use ChannelFlag.fromShift to check for unknown ChannelFlags.

val hasUnknownChannelFlag = ChannelFlag.fromShift(23) in channelFlags

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

Functions

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

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

operator fun contains(flags: ChannelFlags): Boolean

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

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

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

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

operator fun minus(flags: ChannelFlags): ChannelFlags

Returns an instance of ChannelFlags 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: ChannelFlag): ChannelFlags

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

operator fun plus(flags: ChannelFlags): ChannelFlags

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

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