All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.cache.data.AttachmentData.kt Maven / Gradle / Ivy

The newest version!
package dev.kord.core.cache.data

import dev.kord.common.entity.AttachmentFlags
import dev.kord.common.entity.DiscordAttachment
import dev.kord.common.entity.Snowflake
import dev.kord.common.entity.optional.Optional
import dev.kord.common.entity.optional.OptionalBoolean
import dev.kord.common.entity.optional.OptionalInt
import dev.kord.common.serialization.DurationInDoubleSeconds
import kotlinx.serialization.Serializable

@Serializable
public data class AttachmentData(
    val id: Snowflake,
    val filename: String,
    val description: Optional = Optional.Missing(),
    val contentType: Optional = Optional.Missing(),
    val size: Int,
    val url: String,
    val proxyUrl: String,
    val height: OptionalInt? = OptionalInt.Missing,
    val width: OptionalInt? = OptionalInt.Missing,
    val ephemeral: OptionalBoolean = OptionalBoolean.Missing,
    val durationSecs: Optional = Optional.Missing(),
    val waveform: Optional = Optional.Missing(),
    val flags: Optional = Optional.Missing(),
) {
    public companion object {
        public fun from(entity: DiscordAttachment): AttachmentData = with(entity) {
            AttachmentData(
                id,
                filename,
                description,
                contentType,
                size,
                url,
                proxyUrl,
                height,
                width,
                ephemeral,
                durationSecs,
                waveform,
                flags,
            )
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy