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

commonMain.cache.DataCacheExtensions.kt Maven / Gradle / Ivy

The newest version!
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,
    EntitlementData.description,
    SubscriptionData.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()
    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)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy