commonMain.cache.DataCacheExtensions.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.cache
import dev.kord.cache.api.DataCache
import dev.kord.cache.api.query
import dev.kord.common.annotation.KordInternal
import dev.kord.core.cache.data.*
/**
* Registers all Kord data classes for this cache
*
* @suppress
*/
@KordInternal
public suspend fun DataCache.registerKordData(): Unit = register(
RoleData.description,
ChannelData.description,
GuildData.description,
MemberData.description,
UserData.description,
ThreadMemberData.description,
MessageData.description,
EmojiData.description,
WebhookData.description,
PresenceData.description,
VoiceStateData.description,
ApplicationCommandData.description,
GuildApplicationCommandPermissionsData.description,
StickerPackData.description,
StickerData.description,
AutoModerationRuleData.description,
)
/**
* Removes all cached Kord data instances from this cache
*/
internal suspend fun DataCache.removeKordData() {
query().remove()
query().remove()
query().remove()
query().remove()
query().remove()
query().remove()
query().remove()
query().remove()
query().remove()
query().remove()
query().remove()
query().remove()
query().remove()
query().remove()
query().remove()
query().remove()
}
/**
* Creates a [DataCacheView] for this view, only removing elements that were added
* directly to this instance.
*/
public fun DataCache.createView(): DataCacheView = DataCacheView(this)