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

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

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 kotlinx.serialization.Serializable

public val PresenceData.id: String get() = "$userId$guildId"

@Serializable
public data class PresenceData(
    val userId: Snowflake,
    val guildId: Snowflake,
    val status: PresenceStatus,
    val activities: List,
    val clientStatus: ClientStatusData,
) {
    public companion object {
        public val description: DataDescription = description(PresenceData::id)

        public fun from(guildId: Snowflake, entity: DiscordPresenceUpdate): PresenceData = with(entity) {
            PresenceData(
                user.id,
                guildId,
                status,
                activities.map { ActivityData.from(it) },
                ClientStatusData.from(clientStatus),
            )
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy