Home Manual Reference Source Repository
import SettingStorage from 'discord-graf/src/storage/settings.js'
public class | source

SettingStorage

Extends:

src/storage/..js~GuildStorage → SettingStorage

Stores settings within a guild

Constructor Summary

Public Constructor
public

constructor(localStorage: LocalStorage, logger: Logger)

Method Summary

Public Methods
public

delete(guild: Guild | string, setting: Setting | string): boolean

Deletes a setting from the storage

public

exists(guild: Guild | string, setting: Setting | string): boolean

Checks if a setting associated with a guild exists

public

find(guild: Guild | string, setting: Setting | string): *[]

Finds all settings associated with a guild or a single one with a key

public

getValue(guild: Guild | string, setting: Setting | string, defaultValue: *): *

Gets the value of a setting associated with a guild

public

save(setting: Setting): boolean

Saves a setting to the storage

Public Constructors

public constructor(localStorage: LocalStorage, logger: Logger) source

Params:

NameTypeAttributeDescription
localStorage LocalStorage

The LocalStorage instance to use

logger Logger
  • optional

The logger to use

Public Methods

public delete(guild: Guild | string, setting: Setting | string): boolean source

Deletes a setting from the storage

Params:

NameTypeAttributeDescription
guild Guild | string
  • optional

The guild or guild ID the setting is associated with

setting Setting | string

The setting or setting key (must be a setting instance if the guild isn't specified)

Return:

boolean

Whether or not the setting was deleted

See:

public exists(guild: Guild | string, setting: Setting | string): boolean source

Checks if a setting associated with a guild exists

Params:

NameTypeAttributeDescription
guild Guild | string
  • optional

The guild or guild ID the setting is associated with

setting Setting | string

The setting or setting key

Return:

boolean

Whether or not the setting exists

See:

public find(guild: Guild | string, setting: Setting | string): *[] source

Finds all settings associated with a guild or a single one with a key

Params:

NameTypeAttributeDescription
guild Guild | string
  • optional

The guild or guild ID to find the settings of

setting Setting | string

The setting or setting key (must be a setting instance if the guild isn't specified)

Return:

*[]

All found setting values

See:

public getValue(guild: Guild | string, setting: Setting | string, defaultValue: *): * source

Gets the value of a setting associated with a guild

Params:

NameTypeAttributeDescription
guild Guild | string
  • optional

The guild or guild ID the setting is associated with

setting Setting | string

The setting or setting key (must be a setting instance if the guild isn't specified)

defaultValue *
  • optional
  • default: null

The value to default to if the setting doesn't exist

Return:

*

The value of the setting

public save(setting: Setting): boolean source

Saves a setting to the storage

Params:

NameTypeAttributeDescription
setting Setting

The setting to save

Return:

boolean

Whether or not the setting was saved

See: