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

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

There is a newer version: 0.15.0
Show newest version
package dev.kord.core.cache.data

import dev.kord.common.entity.Snowflake
import dev.kord.common.entity.optional.Optional
import dev.kord.common.entity.optional.mapList
import dev.kord.gateway.GuildMembersChunkData
import kotlinx.serialization.Serializable

@Serializable
public data class MembersChunkData(
    val guildId: Snowflake,
    val members: Set,
    val users: Set,
    val chunkIndex: Int,
    val chunkCount: Int,
    val notFound: Optional> = Optional.Missing(),
    val presences: Optional> = Optional.Missing(),
    val nonce: Optional = Optional.Missing(),
) {
    public companion object {

        public fun from(entity: GuildMembersChunkData): MembersChunkData = with(entity) {
            MembersChunkData(
                guildId,
                members.map { MemberData.from(userId = it.user.value!!.id, guildId = guildId, it) }.toSet(),
                members.map { UserData.from(it.user.value!!) }.toSet(),
                chunkIndex,
                chunkCount,
                notFound,
                presences.mapList { PresenceData.from(guildId, it) },
                nonce
            )
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy