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
}
Content copied to clipboard
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
}
Content copied to clipboard
Mathematical operators
All UserFlags objects can use +
/-
operators:
val userFlags1 = userFlags + UserFlag.DiscordEmployee
val userFlags2 = userFlags - UserFlag.DiscordPartner
val userFlags3 = userFlags1 + userFlags2
Content copied to clipboard
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
Content copied to clipboard
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
Content copied to clipboard