Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GuildCache

Cache responsible for guilds

Hierarchy

Index

Methods

addToIndex

  • addToIndex(id: string): Promise<void>
  • Add a guild to the guild index

    Parameters

    • id: string

      ids of the guilds

    Returns Promise<void>

bindGuild

  • Bind a guild id to the cache

    Parameters

    • guildId: string

      id of the guild that should be bound to this cache

    Returns GuildCache

bindObject

  • bindObject(boundObject: Partial<GuildData>): void
  • Bind an object to the cache instance, you can read more on binding on the landing page of the documentation

    Parameters

    • boundObject: Partial<GuildData>

      Object to bind to this cache instance

    Returns void

buildId

  • buildId(id: string): string
  • Build an id consisting of $namespace.$id

    Parameters

    • id: string

      id to append to namespace

    Returns string

    constructed id

filter

  • filter(fn: (emoji?: GuildData, index?: number, array?: GuildData[]) => unknown): Promise<GuildCache[]>
  • Filter through the collection of guilds

    Parameters

    • fn: (emoji?: GuildData, index?: number, array?: GuildData[]) => unknown

      Filter function

        • (emoji?: GuildData, index?: number, array?: GuildData[]): unknown
        • Parameters

          • Optional emoji: GuildData
          • Optional index: number
          • Optional array: GuildData[]

          Returns unknown

    Returns Promise<GuildCache[]>

    array of bound guild caches

find

  • find(fn: (emoji?: GuildData, index?: number, array?: string[]) => unknown): Promise<null | GuildCache>
  • Filter through the collection of guilds and return the first match

    Parameters

    • fn: (emoji?: GuildData, index?: number, array?: string[]) => unknown

      Filter function

        • (emoji?: GuildData, index?: number, array?: string[]): unknown
        • Parameters

          • Optional emoji: GuildData
          • Optional index: number
          • Optional array: string[]

          Returns unknown

    Returns Promise<null | GuildCache>

    returns a bound guild cache

get

  • Retrieves a guild via id

    Parameters

    • id: string

      Discord id of the guild

    Returns Promise<null | GuildCache>

    Returns either a Guild Object or null if the guild does not exist.

getIndexCount

  • Get the number of guilds that are currently cached

    Returns Promise<number>

    Number of guilds currently cached

getIndexMembers

  • getIndexMembers(): Promise<string[]>
  • Get all guild ids currently indexed

    Returns Promise<string[]>

    array of guild ids

isIndexed

  • isIndexed(id: string): Promise<boolean>
  • Check if a guild is indexed alias cached

    Parameters

    • id: string

      id of the guild

    Returns Promise<boolean>

    True if this guild is cached and false if not

remove

  • Removes a guild and associated elements from the cache.

    Parameters

    • id: string

      id of the guild to remove

    Returns Promise<void>

removeFromIndex

  • removeFromIndex(id: string): Promise<void>
  • Remove a guild from the guild index

    Parameters

    • id: string

      id of the guild

    Returns Promise<void>

removeIndex

  • Remove the guild index, you should probably not call this at all :<

    Returns Promise<void>

structurize

  • structurize<D>(data: Partial<D>): Partial<D>
  • Delete keys from data if necessary based on RainCache structureDefs options and return the cleaned data

    Type parameters

    • D

    Parameters

    • data: Partial<D>

      The data to possibly delete object entries from

    Returns Partial<D>

update

  • Upsert a guild object

    Parameters

    • id: string

      id of the guild

    • data: Partial<GuildData>

      data received from the event

    Returns Promise<GuildCache>

    returns a bound guild cache

Properties

Optional boundGuild

boundGuild?: string

guild id bound to this cache

boundObject

boundObject: null | Partial<GuildData> = null

channelCache

channelCache: ChannelCache

dataTimestamp

dataTimestamp: null | Date = null

emojiCache

emojiCache: EmojiCache

guildChannelMap

guildChannelMap: ChannelMapCache

memberCache

memberCache: MemberCache

namespace

namespace: "guild" = "guild"

presenceCache

presenceCache: PresenceCache

rain

rain: RainCache<any, any>

roleCache

roleCache: RoleCache

storageEngine

storageEngine: BaseStorageEngine<GuildData>

Constructors

constructor

  • Create a new GuildCache

    This class is automatically instantiated by RainCache

    Parameters

    • storageEngine: BaseStorageEngine<GuildData>

      Storage engine to use for this cache

    • channelCache: ChannelCache

      Instantiated ChannelCache class

    • roleCache: RoleCache

      Instantiated RoleCache class

    • memberCache: MemberCache

      Instantiated MemberCache class

    • emojiCache: EmojiCache

      Instantiated EmojiCache class

    • presenceCache: PresenceCache

      Instantiated PresenceCache class

    • guildToChannelCache: ChannelMapCache

      Instantiated ChannelMap class

    • rain: RainCache<any, any>
    • Optional boundObject: Partial<GuildData>

      Optional, may be used to bind a guild object to the cache

    Returns GuildCache

Generated using TypeDoc