new SettingGateway(store, type, validateFunction, schema)
Parameters:
Name | Type | Description |
---|---|---|
store |
SettingCache | The SettingCache instance which initiated this SettingGateway |
type |
string | The name of this instance of SettingGateway. |
validateFunction |
function | The function validator for this instance of SettingGateway |
schema |
Object | The schema for this instance of SettingGateway |
Extends
Properties
-
<readonly> client :KlasaClient
-
The client this SettingGateway was created with.
Type:
-
data
-
The data stored for this SettingGateway instance.
- Inherited From:
- Overrides:
- Source:
- lib/settings/CacheManager.js#L20
-
defaultDataSchema :object
-
The schema for this instance of SettingGateway.
Type:
- object
-
defaults
-
The default values for this SchemaManager instance.
- Inherited From:
- Overrides:
- Source:
- lib/settings/SchemaManager.js#L27
-
engine :string
-
The provider engine this instance of SettingGateway should use to handle your settings.
Type:
- string
-
<readonly> provider :Provider
-
The provider this SettingGateway instance uses for the persistent data operations.
Type:
-
<readonly> resolver :Resolver
-
The resolver instance this SettingGateway uses to parse the data.
Type:
-
schema
-
The schema created for this SchemaManager instance.
- Inherited From:
- Overrides:
- Source:
- lib/settings/SchemaManager.js#L22
-
<nullable> sql :SQL
-
If the provider is SQL, this property is on charge to serialize/deserialize.
Type:
-
<readonly> store :SettingCache
-
The SettingCache instance which initiated this SettingGateway.
Type:
- SettingCache
-
sync
-
Sync either all entries from the configuration, or a single one.
-
type :string
-
The name of this instance of SettingGateway. The schema will be saved under 'name_Schema.json'.
Type:
- string
-
validate :function
-
The function validator for this instance of SettingGateway.
Type:
- function
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. - Inherited From:
- Overrides:
- Source:
- lib/settings/SchemaManager.js#L86
Returns:
- Type
- void
Example
1 2 3 4 5
// 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 });
-
<async> create(input)
-
Create a new entry in the configuration.
Parameters:
Name Type Description input
Object | string An object containing a id property, like discord.js objects, or a string. Returns:
- Type
- void
-
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
-
<async> destroy(input)
-
Remove an entry from the configuration.
Parameters:
Name Type Description input
string A key to delete from the cache. Returns:
- Type
- void
-
<async> ensureCreate(target)
-
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:
- Type
- true
-
get(input)
-
Get an entry from the cache.
Parameters:
Name Type Description input
string A key to get the value for. - Overrides:
- Source:
- lib/settings/SettingGateway.js#L110
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> getResolved(input [, guild])
-
Updates an entry.
Parameters:
Name Type Argument Default Description input
Object | string An object containing a id property, like Discord.js objects, or a string. guild
external:Guild <optional>
null A Guild resolvable, useful for when the instance of SG doesn't aim for Guild settings. Returns:
- Type
- Object
-
<async> init()
-
Initialize the configuration for this gateway.
Returns:
- Type
- void
-
<async> initSchema()
-
Initialize the SchemaManager.
- Inherited From:
- Overrides:
- 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. - Inherited From:
- Overrides:
- Source:
- lib/settings/SchemaManager.js#L116
Returns:
- Type
- void
Example
-
<async> reset(input, key)
-
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:
- Type
- any
-
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
-
<async> update(input, object [, guild])
-
Updates an entry.
Parameters:
Name Type Argument 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:
- Type
- Object
-
<async> updateArray(input, action, key, data)
-
Update an array from the configuration.
Parameters:
Name Type Description input
Object | string An object containing a id property, like discord.js objects, or a string. action
'add' | 'remove' Either 'add' or 'remove'. key
string The key from the Schema. data
any The value to be added or removed. Returns:
- Type
- boolean
-
validateSchema(schema)
-
Validate the Schema manager.
Parameters:
Name Type Description schema
Object The Schema object that will be used for the configuration system. - Inherited From:
- Overrides:
- Source:
- lib/settings/SchemaManager.js#L48
Returns:
- Type
- void