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

commonMain.event.role.RoleCreateEvent.kt Maven / Gradle / Ivy

The newest version!
package dev.kord.core.event.role

import dev.kord.common.entity.Snowflake
import dev.kord.core.Kord
import dev.kord.core.behavior.GuildBehavior
import dev.kord.core.entity.Guild
import dev.kord.core.entity.Role
import dev.kord.core.entity.Strategizable
import dev.kord.core.event.Event
import dev.kord.core.supplier.EntitySupplier
import dev.kord.core.supplier.EntitySupplyStrategy

public class RoleCreateEvent(
    public val role: Role,
    override val shard: Int,
    override val customContext: Any?,
    override val supplier: EntitySupplier = role.kord.defaultSupplier,
) : Event, Strategizable {

    override val kord: Kord get() = role.kord

    public val guildId: Snowflake get() = role.guildId

    public val guild: GuildBehavior get() = GuildBehavior(guildId, kord)

    public suspend fun getGuild(): Guild = supplier.getGuild(guildId)

    public suspend fun getGuildOrNull(): Guild? = supplier.getGuildOrNull(guildId)

    override fun withStrategy(strategy: EntitySupplyStrategy<*>): RoleCreateEvent =
        RoleCreateEvent(role, shard, customContext, strategy.supply(kord))

    override fun toString(): String {
        return "RoleCreateEvent(role=$role, shard=$shard, supplier=$supplier)"
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy