An abstract DataProvider, it contains all the methods that need to be implemented for any DataProvider with a custom backend.

Hierarchy

  • DataProvider

Constructors

Properties

The client that this data provider will be used by.

Memberof

DataProvider

Methods

  • Delete a key-value pair in a guild and return the old value. If the key does not exist, this function should return undefined.

    Type Parameters

    • T = any

    Parameters

    • guild: Guild

      The guild for which the key-value pair will be deleted.

    • key: string

      The key to delete.

    Returns Promise<undefined | T>

    A promise that resolves the data that was deleted.

  • Delete a key-value pair in a global scope and return the old value. If the key does not exist, this function should return undefined.

    Type Parameters

    • T = any

    Parameters

    • key: string

      The key to delete.

    Returns Promise<undefined | T>

    A promise that resolves the data that was deleted.

  • Gracefully destroy this data provider. This should close any connections. The instance should be unusable after calling this method.

    Returns Promise<void>

    A promise that resolves once this data provider is destroyed.

    Emits

    client#dataProviderDestroy

  • Get a value for a key in a guild. If no value is found, this method should return undefined if no defaultValue is provided.

    Type Parameters

    • T = any

    Parameters

    • guild: Guild

      The guild for which the data will be queried.

    • key: string

      The key of the data to be queried.

    Returns Promise<undefined | T>

    A promise that resolves the queried data.

  • Get a value for a key in a guild. If no value is found, this method should return undefined if no defaultValue is provided.

    Type Parameters

    • T = any

    Parameters

    • guild: Guild

      The guild for which the data will be queried.

    • key: string

      The key of the data to be queried.

    • defaultValue: T

      The default value in case there is no entry found.

    Returns Promise<T>

    A promise that resolves the queried data.

  • Get a value for a key in a guild. If no value is found, this method should return undefined if no defaultValue is provided.

    Type Parameters

    • T = any

    Parameters

    • guild: Guild

      The guild for which the data will be queried.

    • key: string

      The key of the data to be queried.

    • Optional defaultValue: T

      The default value in case there is no entry found.

    Returns Promise<undefined | T>

    A promise that resolves the queried data.

  • Get a value for a key in a global scope. If no value is found, this method should return undefined if no defaultValue is provided.

    Type Parameters

    • T = any

    Parameters

    • key: string

      The key of the data to be queried.

    Returns Promise<undefined | T>

    A promise that resolves the queried data.

  • Get a value for a key in a global scope. If no value is found, this method should return undefined if no defaultValue is provided.

    Type Parameters

    • T = any

    Parameters

    • key: string

      The key of the data to be queried.

    • defaultValue: T

      The default value in case there is no entry found.

    Returns Promise<T>

    A promise that resolves the queried data.

  • Get a value for a key in a global scope. If no value is found, this method should return undefined if no defaultValue is provided.

    Type Parameters

    • T = any

    Parameters

    • key: string

      The key of the data to be queried.

    • Optional defaultValue: T

      The default value in case there is no entry found.

    Returns Promise<undefined | T>

    A promise that resolves the queried data.

  • Initialize this data provider. Database connection and instantiation should be done here. If the data provider is already initialized, this method should not reinitialize it.

    Returns Promise<DataProvider>

    A promise that resolves this data provider once it's ready.

    Emits

    client#dataProviderInit

  • Set a value for a key in a guild.

    Type Parameters

    • T = any

    Parameters

    • guild: Guild

      The guild for which the data will be set.

    • key: string

      The key of the data to be set.

    • value: T

      The value to set.

    Returns Promise<void>

    A promise that resolves once the data is saved.

  • Set a value for a key in a global scope.

    Type Parameters

    • T = any

    Parameters

    • key: string

      The key of the data to be set.

    • value: T

      The value to set.

    Returns Promise<void>

    A promise that resolves once the data is saved.

Generated using TypeDoc