commonMain.cache.data.EmojiData.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kord-core-jvm Show documentation
Show all versions of kord-core-jvm Show documentation
Idiomatic Kotlin Wrapper for The Discord API
package dev.kord.core.cache.data
import dev.kord.cache.api.data.DataDescription
import dev.kord.cache.api.data.description
import dev.kord.common.entity.DiscordEmoji
import dev.kord.common.entity.Snowflake
import dev.kord.common.entity.optional.*
import kotlinx.serialization.Serializable
@Serializable
public data class EmojiData(
val id: Snowflake,
val guildId: Snowflake,
val name: String? = null,
val userId: OptionalSnowflake = OptionalSnowflake.Missing,
val roles: Optional> = Optional.Missing(),
val requireColons: OptionalBoolean = OptionalBoolean.Missing,
val managed: OptionalBoolean = OptionalBoolean.Missing,
val animated: OptionalBoolean = OptionalBoolean.Missing,
val available: OptionalBoolean = OptionalBoolean.Missing
) {
public companion object {
public val description: DataDescription = description(EmojiData::id)
public fun from(guildId: Snowflake, id: Snowflake, entity: DiscordEmoji): EmojiData =
with(entity) {
EmojiData(
id,
guildId,
name,
user.value?.id.optionalSnowflake() ?: OptionalSnowflake.Missing,
roles,
requireColons,
managed,
animated,
available,
)
}
}
}
public fun DiscordEmoji.toData(guildId: Snowflake, id: Snowflake): EmojiData {
return EmojiData.from(guildId, id, this)
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy