Options
All
  • Public
  • Public/Protected
  • All
Menu

Class VoiceStateCache

Cache responsible for caching users

Hierarchy

Index

Methods

addToIndex

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

    Parameters

    • id: string

      id of the voice state

    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 VoiceStateCache

bindObject

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

    Parameters

    • boundObject: Partial<VoiceStateData>

      Object to bind to this cache instance

    Returns void

bindUserId

  • Bind a user id to the cache

    Parameters

    • userId: string

      id of the user

    Returns VoiceStateCache

    Returns a VoiceStateCache that has an id bound to it, which serves as the default argument to get, update and delete

buildId

  • buildId(userId: string, guildId?: string): string
  • Build a unique key for storing VoiceState data

    Parameters

    • userId: string

      id of the user

    • Optional guildId: string

      id of the guild

    Returns string

filter

  • filter(fn: (state?: VoiceStateData, index?: number, array?: VoiceStateData[]) => unknown, ids?: undefined | string[]): Promise<VoiceStateCache[]>
  • Filter for VoiceStates by providing a filter function which returns true upon success and false otherwise

    Parameters

    • fn: (state?: VoiceStateData, index?: number, array?: VoiceStateData[]) => unknown

      filter function to use for the filtering

        • (state?: VoiceStateData, index?: number, array?: VoiceStateData[]): unknown
        • Parameters

          • Optional state: VoiceStateData
          • Optional index: number
          • Optional array: VoiceStateData[]

          Returns unknown

    • ids: undefined | string[] = undefined

      Array of user ids, if omitted the global user index will be used

    Returns Promise<VoiceStateCache[]>

find

  • find(fn: (state?: VoiceStateData, index?: number, array?: string[]) => unknown, ids?: undefined | string[]): Promise<null | VoiceStateCache>
  • Find a VoiceState by providing a filter function which returns true upon success and false otherwise

    Parameters

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

      filter function to use for filtering for a state

        • (state?: VoiceStateData, index?: number, array?: string[]): unknown
        • Parameters

          • Optional state: VoiceStateData
          • Optional index: number
          • Optional array: string[]

          Returns unknown

    • ids: undefined | string[] = undefined

      List of ids that should be used as the scope of the filter

    Returns Promise<null | VoiceStateCache>

    Returns a VoiceState Cache with a bound state or null if no state was found

get

  • Loads a VoiceState from the cache via id

    Parameters

    • id: string = ...

      discord id of the user

    • guildId: string

      guild id

    Returns Promise<null | VoiceStateCache>

    Returns a VoiceState Cache with a bound user or null if no user was found

getIndexCount

  • Get the number of VoiceStates that are currently cached

    Returns Promise<number>

    Number of VoiceStates currently cached

getIndexMembers

  • getIndexMembers(): Promise<string[]>
  • Get a list of currently indexed VoiceStates, since VoiceStates is a global namespace, this will return ALL VoiceStates that the bot cached currently

    Returns Promise<string[]>

    Array with a list of ids of users that are indexed

isIndexed

  • isIndexed(id: string, guildId?: string): Promise<boolean>
  • Check if a VoiceState is indexed

    Parameters

    • id: string

      id of the user

    • Optional guildId: string

    Returns Promise<boolean>

    True if the state is indexed, false otherwise

remove

  • remove(id?: string, guildId: string): Promise<void>
  • Remove a VoiceState from the cache

    Parameters

    • id: string = ...

      discord id of the user

    • guildId: string

      guild id

    Returns Promise<void>

removeFromIndex

  • removeFromIndex(id: string, guildId?: string): Promise<void>
  • Remove a VoiceState from the index

    Parameters

    • id: string

      id of the user

    • Optional guildId: string

    Returns Promise<void>

removeIndex

  • Delete the VoiceState index, you should probably not use this function, but I won't stop you.

    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

  • Update a VoiceState entry in the cache

    Parameters

    • id: string

      discord id of the user

    • guildId: string

      guild id

    • data: Partial<VoiceStateData>

      updated data of the VoiceState, it will be merged with the old data

    Returns Promise<VoiceStateCache>

Properties

Optional boundGuild

boundGuild?: string

guild id bound to this cache

boundObject

boundObject: null | Partial<VoiceStateData> = null

dataTimestamp

dataTimestamp: null | Date = null

namespace

namespace: "voicestates" = "voicestates"

rain

rain: RainCache<any, any>

storageEngine

storageEngine: BaseStorageEngine<VoiceStateData>

Constructors

constructor

  • Create a new VoiceStateCache

    This class is automatically instantiated by RainCache

    Parameters

    • storageEngine: BaseStorageEngine<VoiceStateData>

      Storage engine to use for this cache

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

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

    Returns VoiceStateCache

Generated using TypeDoc