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

commonMain.builder.guild.WelcomeScreenModifyBuilder.kt Maven / Gradle / Ivy

The newest version!
package dev.kord.rest.builder.guild

import dev.kord.common.annotation.KordDsl
import dev.kord.common.entity.DiscordWelcomeScreenChannel
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.delegate.delegate
import dev.kord.common.entity.optional.mapList
import dev.kord.rest.builder.AuditRequestBuilder
import dev.kord.rest.builder.RequestBuilder
import dev.kord.rest.json.request.GuildWelcomeScreenModifyRequest
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract

@KordDsl
public class WelcomeScreenModifyBuilder : AuditRequestBuilder {

    override var reason: String? = null

    private var _enabled: OptionalBoolean = OptionalBoolean.Missing

    public var enabled: Boolean? by ::_enabled.delegate()
    private var _description: Optional = Optional.Missing()

    public var description: String? by ::_description.delegate()
    private var _welcomeScreenChannels: Optional> = Optional.Missing()

    public var welcomeScreenChannels: MutableList? by ::_welcomeScreenChannels.delegate()

    public inline fun welcomeChannel(
        id: Snowflake,
        description: String,
        builder: WelcomeScreenChannelBuilder.() -> Unit,
    ) {
        contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) }
        if (welcomeScreenChannels == null) welcomeScreenChannels = mutableListOf()
        welcomeScreenChannels!!.add(WelcomeScreenChannelBuilder(id, description, null, null).apply(builder))
    }

    override fun toRequest(): GuildWelcomeScreenModifyRequest {
        return GuildWelcomeScreenModifyRequest(
            _enabled,
            _welcomeScreenChannels.mapList { it.toRequest() },
            _description
        )
    }

}

@KordDsl
public class WelcomeScreenChannelBuilder(
    public var channelId: Snowflake,
    public var description: String,
    public var emojiId: Snowflake?,
    public var emojiName: String?,
) : RequestBuilder {
    override fun toRequest(): DiscordWelcomeScreenChannel {
        return DiscordWelcomeScreenChannel(channelId, description, emojiId, emojiName)
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy