Gateway(settings, validateFunction)

The gateway for this settings instance. The gateway handles all the creation and setting of non-default entries, along with saving.

new Gateway(settings, validateFunction)

Constructs our instance of Gateway
Parameters:
Name Type Description
settings any The settings that created this gateway.
validateFunction any The validation function used to validate user input.

Members

static, readonly settings :Settings

The Settings class that this gateway is a part of.

readonly cache :Cache

The cache created with this instance

readonly client :KomadaClient

The client this SettingGateway was created with.

engine :string

The provider engine that will handle saving and getting all data for this instance.

readonly provider :Provider

The provider this SettingGateway instance uses for the persistent data operations.

readonly resolver :Resolver

The resolver instance this SettingGateway uses to parse the data.

readonly schema :Schema

The schema this gateway instance is handling.

sql :string

If the provider is SQL, this property will ensure data is serialized and deserialized.

readonly type :string

The type of settings (or name).

validate :function

The function validator for this gateway.

Methods

async create(input)

Creates a new entry in the cache.
Parameters:
Name Type Description
input Object | string An object containing a id property, like discord.js objects, or a string.

async destroy(input)

Removes an entry from the cache.
Parameters:
Name Type Description
input Object | string An object containing a id property, like discord.js objects, or a string.

async ensureCreate(target) → {true}

Creates the settings if it did not exist previously.
Parameters:
Name Type Description
target Object | string An object or string that can be parsed by this instance's resolver.
Returns:
true

get(input) → {Schema}

Gets an entry from the cache
Parameters:
Name Type Description
input string The key you are you looking for.
Returns:
Schema

async init(schema) → {void}

Initializes the gateway, creating tables, ensuring the schema exists, and caching values.
Parameters:
Name Type Description
schema Schema The Schema object, validated from settings.
Returns:
void

async reset(input, key) → {any}

Reset a key's value to default from a entry.
Parameters:
Name Type Description
input Object | string An object containing a id property, like Discord.js objects, or a string.
key string The key to reset.
Returns:
any

async sync(inputopt) → {void}

Sync either all entries from the provider, or a single one.
Parameters:
Name Type Attributes Default Description
input Object | string <optional>
null An object containing a id property, like discord.js objects, or a string.
Returns:
void

async update(input, object, guildopt) → {Object}

Updates an entry.
Parameters:
Name Type Attributes Default Description
input Object | string An object or string that can be parsed by this instance's resolver.
object Object An object with pairs of key/value to update.
guild Object | string <optional>
null A Guild resolvable, useful for when the instance of SG doesn't aim for Guild settings.
Returns:
Object

async updateArray(input, type, key, data, guildopt) → {boolean}

Update an array from the a Guild's configuration.
Parameters:
Name Type Attributes Default Description
input Object | string An object containing a id property, like discord.js objects, or a string.
type string Either 'add' or 'remove'.
key string The key from the Schema.
data any The value to be added or removed.
guild Object | string <optional>
null The guild for this setting, useful for when the settings aren't aimed for guilds
Returns:
boolean