Class: SchemaManager

SchemaManager

The Schema driver for SettingGateway

new SchemaManager(client)

Parameters:
Name Type Description
client KlasaClient The Klasa client
Source:
lib/settings/SchemaManager.js#L16

Extends

Properties


data

The data stored for this SettingGateway instance.
Inherited From:
Overrides:
Source:
lib/settings/CacheManager.js#L20

defaults

The default values for this SchemaManager instance.
Source:
lib/settings/SchemaManager.js#L27

schema

The schema created for this SchemaManager instance.
Source:
lib/settings/SchemaManager.js#L22

Methods


<async> add(key, options [, force])

Add a new key to the schema.
Parameters:
Name Type Argument Default Description
key string The key to add.
options AddOptions Options for the key.
force boolean <optional>
true Whether this change should modify all configurations or not.
Source:
lib/settings/SchemaManager.js#L86
Returns:
Type
void
Example
// Add a key called 'modlog', being a TextChannel.
SchemaManager.add('modlog', { type: 'TextChannel' });

// Add a key called 'playlist-length', being an Integer with minimum value of 5 and max 20, being 15 by default.
SchemaManager.add('playlist-length', { type: 'Integer', default: 15, min: 5, max: 20 });

delete(key)

Delete the selected data from the cache by its ID.
Parameters:
Name Type Description
key string The data's key.
Inherited From:
Overrides:
Source:
lib/settings/CacheManager.js#L58
Returns:
Type
any

get(key)

Get the data from the cache by its ID.
Parameters:
Name Type Description
key string The key to search for.
Inherited From:
Overrides:
Source:
lib/settings/CacheManager.js#L28
Returns:
Type
Object

getAll()

Get all the data from the cache as an array of objects.
Inherited From:
Overrides:
Source:
lib/settings/CacheManager.js#L37
Returns:
Type
Array.<Object>

<async> initSchema()

Initialize the SchemaManager.
Source:
lib/settings/SchemaManager.js#L34
Returns:
Type
void

<async> remove(key [, force])

Remove a key from the schema.
Parameters:
Name Type Argument Default Description
key string The key to remove.
force boolean <optional>
false Whether this change should modify all configurations or not.
Source:
lib/settings/SchemaManager.js#L116
Returns:
Type
void
Example
// Remove a key called 'modlog'.
SchemaManager.remove('modlog');

set(key, value)

Save a new data to the cache.
Parameters:
Name Type Description
key string The data's key.
value Object The data's value.
Inherited From:
Overrides:
Source:
lib/settings/CacheManager.js#L48
Returns:
Type
any

validateSchema(schema)

Validate the Schema manager.
Parameters:
Name Type Description
schema Object The Schema object that will be used for the configuration system.
Source:
lib/settings/SchemaManager.js#L48
Returns:
Type
void

Type Definitions


AddOptions

Type:
  • Object
Properties:
Name Type Description
type string The type for the key.
default any The default value for the key.
min number The min value for the key (String.length for String, value for number).
max number The max value for the key (String.length for String, value for number).
array boolean Whether the key should be stored as Array or not.
Source:
lib/settings/SchemaManager.js#L63