Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RoleCache

Cache responsible for storing role related data

Hierarchy

Index

Methods

addToIndex

  • addToIndex(id: string, objectId?: string): Promise<void>
  • Add ids to the index of a namespace

    Parameters

    • id: string

      ids to add

    • objectId: string = ...

      id of the parent object of the index

    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 RoleCache

bindObject

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

    Parameters

    • boundObject: Partial<RoleData>

      Object to bind to this cache instance

    Returns void

buildId

  • buildId(roleId: string, guildId?: string): string
  • Build a unique key for the role cache entry

    Parameters

    • roleId: string

      id of the role

    • Optional guildId: string

      id of the guild belonging to the role

    Returns string

    the prepared key

filter

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

    Parameters

    • fn: (role?: RoleData, index?: number, array?: RoleData[]) => unknown

      filter function to use for the filtering

        • (role?: RoleData, index?: number, array?: RoleData[]): unknown
        • Parameters

          • Optional role: RoleData
          • Optional index: number
          • Optional array: RoleData[]

          Returns unknown

    • guildId: undefined | string = ...

      id of the guild belonging to the roles

    • ids: undefined | string[] = undefined

      array of role ids that should be used for the filtering

    Returns Promise<RoleCache[]>

    array of bound role caches

find

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

    Parameters

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

      filter function to use for filtering for a single role

        • (role?: RoleData, index?: number, array?: string[]): unknown
        • Parameters

          • Optional role: RoleData
          • Optional index: number
          • Optional array: string[]

          Returns unknown

    • guildId: undefined | string = ...

      id of the guild belonging to the roles

    • ids: undefined | string[] = undefined

      array of role ids that should be used for the filtering

    Returns Promise<null | RoleCache>

    bound role cache

get

  • Get a role via id and guild id of the role

    Parameters

    • id: string

      id of the role

    • guildId: string

      id of the guild belonging to the role

    Returns Promise<null | RoleCache>

    Returns a Role Cache with a bound role or null if no role was found

getIndexCount

  • getIndexCount(objectId?: string): Promise<number>
  • Get the number of elements that are within an index

    Parameters

    • objectId: string = ...

      id of the parent object of the index

    Returns Promise<number>

getIndexMembers

  • getIndexMembers(objectId?: string): Promise<string[]>
  • Get all members from an index

    Parameters

    • objectId: string = ...

      id of the parent object of the index

    Returns Promise<string[]>

isIndexed

  • isIndexed(id: string, objectId?: string): Promise<boolean>
  • Check if an id is a member of an index

    Parameters

    • id: string

      id to check

    • objectId: string = ...

      id of the parent object of the index

    Returns Promise<boolean>

    returns true if it is a part of the index, false otherwise

remove

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

    Parameters

    • id: string

      id of the role

    • guildId: string

      id of the guild belonging to the role

    Returns Promise<void>

removeFromIndex

  • removeFromIndex(id: string, objectId?: string): Promise<void>
  • Remove an id from the index

    Parameters

    • id: string

      id to be removed

    • objectId: string = ...

      id of the parent object of the index

    Returns Promise<void>

removeIndex

  • removeIndex(objectId?: string): Promise<void>
  • Delete an index

    Parameters

    • objectId: string = ...

      id of the parent object of the index

    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(id: string, guildId: string, data: Partial<RoleData & { guild_id: string }>): Promise<RoleCache>
  • Update a role

    Parameters

    • id: string

      id of the role

    • guildId: string

      id of the guild belonging to the role

    • data: Partial<RoleData & { guild_id: string }>

      new role data

    Returns Promise<RoleCache>

    returns a bound RoleCache once the data was updated.

Properties

Optional boundGuild

boundGuild?: string

guild id bound to this cache

boundObject

boundObject: null | Partial<RoleData> = null

dataTimestamp

dataTimestamp: null | Date = null

namespace

namespace: "role" = "role"

rain

rain: RainCache<any, any>

storageEngine

storageEngine: BaseStorageEngine<RoleData>

Constructors

constructor

  • Create a new RoleCache

    This class is automatically instantiated by RainCache

    Parameters

    • storageEngine: BaseStorageEngine<RoleData>

      Storage engine to use for this cache

    • rain: RainCache<any, any>
    • Optional boundObject: Partial<RoleData & { guild_id: string }>

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

    Returns RoleCache

Generated using TypeDoc