commonMain.cache.data.StickerData.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
The newest version!
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.*
import dev.kord.common.entity.optional.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
public data class StickerData(
val id: Snowflake,
val packId: OptionalSnowflake = OptionalSnowflake.Missing,
val name: String,
val description: String?,
val tags: Optional = Optional.Missing(),
val formatType: MessageStickerType,
val available: OptionalBoolean = OptionalBoolean.Missing,
@SerialName("guild_id")
val guildId: OptionalSnowflake = OptionalSnowflake.Missing,
val user: Optional = Optional.Missing(),
@SerialName("sort_value")
val sortValue: OptionalInt = OptionalInt.Missing
) {
public companion object {
public val description: DataDescription = description(StickerData::id)
public fun from(entity: DiscordMessageSticker): StickerData = with(entity) {
StickerData(id, packId, name, description, tags, formatType, available, guildId, user.map { it.toData() }, sortValue)
}
}
}
@Serializable
public data class StickerItemData(
val id: Snowflake,
val name: String,
val formatType: MessageStickerType
) {
public companion object {
public fun from(entity: DiscordStickerItem): StickerItemData = with(entity) {
StickerItemData(id, name, formatType)
}
}
}
private val StickerData.nullablePackId get() = packId.value
public data class StickerPackData(
val id: Snowflake,
val stickers: List,
val name: String,
val skuId: Snowflake,
val coverStickerId: OptionalSnowflake = OptionalSnowflake.Missing,
val description: String,
val bannerAssetId: Snowflake
) {
public companion object {
public val description: DataDescription = description(StickerPackData::id) {
link(StickerPackData::id to StickerData::nullablePackId)
}
public fun from(entity: DiscordStickerPack): StickerPackData = with(entity) {
StickerPackData(id, stickers.map { StickerData.from(it) }, name, skuId, coverStickerId, description, bannerAssetId)
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy