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

commonMain.cache.data.PartialGuildData.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.*
import dev.kord.common.entity.optional.Optional
import dev.kord.common.entity.optional.OptionalBoolean
import dev.kord.common.entity.optional.map
import dev.kord.common.entity.optional.mapList
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
public class PartialGuildData(
    public val id: Snowflake,
    public val name: String,
    public val icon: String? = null,
    public val owner: OptionalBoolean = OptionalBoolean.Missing,
    public val permissions: Optional = Optional.Missing(),
    public val features: List,
    public val welcomeScreen: Optional = Optional.Missing(),
    @SerialName("vanity_url_code") public val vanityUrlCode: Optional = Optional.Missing(),
    public val description: Optional = Optional.Missing(),
    public val banner: Optional = Optional.Missing(),
    public val splash: Optional = Optional.Missing(),
    @SerialName("nsfw_level") public val nsfwLevel: Optional = Optional.Missing(),
    @SerialName("verification_level")
    public val verificationLevel: Optional = Optional.Missing(),
    public val stageInstances: Optional> = Optional.Missing(),
    public val stickers: Optional> = Optional.Missing(),
    public val guildScheduledEvents: Optional> = Optional.Missing(),
    public val premiumProgressBarEnabled: OptionalBoolean = OptionalBoolean.Missing

) {
    public companion object {
        public fun from(partialGuild: DiscordPartialGuild): PartialGuildData = with(partialGuild) {
            PartialGuildData(
                id,
                name,
                icon,
                owner,
                permissions,
                features,
                welcomeScreen.map { WelcomeScreenData.from(it) },
                vanityUrlCode,
                description,
                banner,
                splash,
                nsfwLevel,
                verificationLevel,
                stageInstances = stageInstances.mapList { StageInstanceData.from(it) },
                stickers = stickers.mapList { StickerData.from(it) },
                guildScheduledEvents = guildScheduledEvents.mapList { GuildScheduledEventData.from(it) },
                premiumProgressBarEnabled = premiumProgressBarEnabled
            )
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy