Settings(client, name, validate, schema, resolver)

new Settings(client, name, validate, schema, resolver)

Creates a new settings instance.
Parameters:
Name Type Description
client KomadaClient The Komada clien
name string The name of these new settings
validate function The validate function for gateway
schema Schema | Object The schema object
resolver SettingResolver The resolver class

Members

baseDir :string

The base directory where this instance will save to.

cache :Cache

The cache used to store data for this instance.

gateway :Gateway

The gateway for this settings instance.

resolver :SettingResolver

The settings resolver used for this instance.

schema :Schema

The schema that we will use for this instance.

schemaPath :string

The path to the schema for this instance.

type :string

The name or type of settings

Methods

async add(name, options, forceopt) → {Promise.<Schema>}

Parameters:
Name Type Attributes Default Description
name string The name of the key you want to add.
options Schema.Options Schema options.
force boolean <optional>
true Whether or not we should force update all settings.
Returns:
Promise.<Schema> - The new schema object

create(input) → {Promisie.<void>}

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.
Returns:
Promisie.<void>

destroy(input) → {Promise.<void>}

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.
Returns:
Promise.<void>

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()

Initializes all of our different components.

async remove(key, forceopt) → {Promise.<Schema>}

Remove a key from the schema.
Parameters:
Name Type Attributes Default Description
key string The key to remove.
force boolean <optional>
false Whether this change should modify all configurations or not.
Returns:
Promise.<Schema> - The new schema object
Example
// Remove a key called 'modlog'.
await client.settings.guilds.remove("modlog");

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

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

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 new setting change, useful for when settings don't aim for guilds.
Returns:
boolean

validateSchema(schema)

Validates our schema. Ensures that the object was created correctly and will not break.
Parameters:
Name Type Description
schema Object | Schema The schema we are validating.