Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ChannelMapCache

Cache for providing a guild/user -> channels map

Hierarchy

Index

Methods

Private _buildMap

Private _buildMapId

  • _buildMapId(id: string, type: string): string
  • Build a unique key id for the channel map

    Parameters

    • id: string

      Id of the guild/user

    • type: string

      Type of the map

    Returns string

Private _checkDupes

  • _checkDupes(oldIds: string[], newIds: string[]): string[]
  • Checks for duplicate ids in the provided arrays

    Parameters

    • oldIds: string[]

      Array of old ids

    • newIds: string[]

      Array of new ids

    Returns string[]

    Array of non duplicated Ids

Private _removeOldChannels

  • _removeOldChannels(oldChannels: string[], removeChannels: string[]): string[]
  • Remove old channels from the array of mapped channels

    Parameters

    • oldChannels: string[]

      Array of old channels

    • removeChannels: string[]

      Array of new channels

    Returns string[]

    Array of filtered channels

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 ChannelMapCache

bindObject

buildId

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

    Parameters

    • id: string

      id to append to namespace

    Returns string

    constructed id

get

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, type?: "guild" | "user"): 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

  • Upsert a ChannelMap

    Parameters

    • id: string

      Id of the user or the guild

    • data: string[]

      Array of channel ids

    • type: "guild" | "user" = "guild"

      Type of the map to upsert

    • remove: boolean = false

      Remove old channels that don't exist anymore

    Returns Promise<ChannelMapCache>

Properties

Optional boundGuild

boundGuild?: string

guild id bound to this cache

boundObject

Optional channels

channels?: string[]

dataTimestamp

dataTimestamp: null | Date = null

Optional id

id?: string

namespace

namespace: "channelmap" = "channelmap"

rain

rain: RainCache<any, any>

storageEngine

Optional type

type?: "guild" | "user"

Constructors

constructor

Generated using TypeDoc