commonMain.event.channel.ChannelPinsUpdateEvent.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kord-core Show documentation
Show all versions of kord-core Show documentation
Idiomatic Kotlin Wrapper for The Discord API
package dev.kord.core.event.channel
import dev.kord.common.entity.Snowflake
import dev.kord.core.Kord
import dev.kord.core.behavior.GuildBehavior
import dev.kord.core.behavior.channel.MessageChannelBehavior
import dev.kord.core.entity.Strategizable
import dev.kord.core.entity.channel.MessageChannel
import dev.kord.core.event.Event
import dev.kord.core.event.channel.data.ChannelPinsUpdateEventData
import dev.kord.core.supplier.EntitySupplier
import dev.kord.core.supplier.EntitySupplyStrategy
import dev.kord.core.supplier.getChannelOf
import dev.kord.core.supplier.getChannelOfOrNull
import kotlinx.datetime.Instant
public class ChannelPinsUpdateEvent(
public val data: ChannelPinsUpdateEventData,
override val kord: Kord,
override val shard: Int,
override val customContext: Any?,
override val supplier: EntitySupplier = kord.defaultSupplier,
) : Event, Strategizable {
public val channelId: Snowflake get() = data.channelId
public val guildId: Snowflake? get() = data.guildId.value
public val lastPinTimestamp: Instant? get() = data.lastPinTimestamp.value
public val guild: GuildBehavior? get() = guildId?.let { GuildBehavior(it, kord) }
public val channel: MessageChannelBehavior get() = MessageChannelBehavior(channelId, kord)
public suspend fun getChannel(): MessageChannel = supplier.getChannelOf(channelId)
public suspend fun getChannelOrNull(): MessageChannel? = supplier.getChannelOfOrNull(channelId)
override fun withStrategy(strategy: EntitySupplyStrategy<*>): ChannelPinsUpdateEvent =
ChannelPinsUpdateEvent(data, kord, shard, customContext, strategy.supply(kord))
override fun toString(): String {
return "ChannelPinsUpdateEvent(channelId=$channelId, lastPinTimestamp=$lastPinTimestamp, kord=$kord, shard=$shard, supplier=$supplier)"
}
}