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

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

There is a newer version: 0.15.0
Show 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.DiscordWebhook
import dev.kord.common.entity.Snowflake
import dev.kord.common.entity.WebhookType
import dev.kord.common.entity.optional.Optional
import dev.kord.common.entity.optional.OptionalSnowflake
import dev.kord.common.entity.optional.mapSnowflake
import kotlinx.serialization.Serializable

@Serializable
public data class WebhookData(
    val id: Snowflake,
    val type: WebhookType,
    val guildId: OptionalSnowflake = OptionalSnowflake.Missing,
    val channelId: Snowflake,
    val userId: OptionalSnowflake = OptionalSnowflake.Missing,
    val name: String? = null,
    val avatar: String? = null,
    val token: Optional = Optional.Missing(),
    val applicationId: Snowflake?
) {
    public companion object {
        public val description: DataDescription = description(WebhookData::id)

        public fun from(entity: DiscordWebhook): WebhookData = with(entity) {
            WebhookData(id, type, guildId, channelId, user.mapSnowflake { it.id }, name, avatar, token, applicationId)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy