Conversation
… Set<string>, massive documentation overhaul
…and GatewayDriver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requested changes marked in example
Things marked in example should just be removed
msg.guild.configs.update('roles.administrator', '339943234405007361', msg.guild); | ||
|
||
// Updating an array | ||
// userBlacklist, as mentioned in another tutorial, it's a piece with an array or users. Using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array of users not or
// Ensuring the function call adds (error if it exists) | ||
msg.guild.configs.update('userBlacklist', '272689325521502208', { action: 'add' }); | ||
|
||
// Ensuring the function call removes (error if it not exists) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error if it doesn't exist
|
||
| Name | Type | Description | | ||
| :-----------------: | :------------------------------------------------ | ---------------------------------------------------------------------------------------- | | ||
| **any** | Anything, no type restriction | Resolves anything, even objects, the usage of this type will make a key unconfigurable | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolves anything, even objects. The usage of this type will make a key unconfigurable
|
||
## Adding new types | ||
|
||
To add new keys, you use an {@link Extendable} extending {@link SettingResolver}. If you don't know how to create an extendable, check the following tutorial: {@tutorial CreatingExtendables}. The following extendable is a template for this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To add new types, not keys, since the title is Adding new types
|
||
A schema works like a diagram or a blueprint, in SettingGateway, the schema defines the keys present in the configuration for a specific gateway. This feature serves multiple purposes: | ||
|
||
1. Define what keys does the {@link Gateway} manage and their properties. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define what keys does the {@link Gateway} manages and their properties.
|
||
## Adding folders | ||
|
||
Folder creation is very similar to key creation, but with one key difference: it has no options for itself, but instead, it can create its children keys (like you can add a box with another boxes and pieces, into another). You can add a new key inside a new folder in two different ways: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(just like you can add a box with other boxes and pieces, into another)
} | ||
``` | ||
|
||
> **Reminder**: To access to a key inside a folder in your configuration command, you use the access operator (`.`). For example: *k!conf set channels.modlogs #modlogs* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To access to a key inside a folder
|
||
## Ensuring the existence of a key. | ||
|
||
In [Klasa-Pieces](https://github.com/dirigeants/klasa-pieces/), specially, some pieces require a key from the configuration to work, however, the creator of the pieces does not know if the user who downloads the piece has it, so this function becomes useful in this case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Klasa-Pieces [REMOVE THE COMMA] especially,
@@ -0,0 +1,67 @@ | |||
# Understanding Schema's Keys | |||
|
|||
As mentioned in the previous tutorial, {@tutorial UnderstandingSchema}, SettingGateway's schema is divided in two parts: **folders** and **pieces**. Pieces are contained into folders, but it cannot have keys nor folders, instead, this holds the key's metadata such as its type, if it's configurable by the configuration command... you can check more information in the documentation: {@link SchemaPiece}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said in Discord, calling items in the schema as **folders** and **pieces**
and also calling commands, events, extendables, inhibitors
'pieces' as well might be confusing to new users
Pieces are contained in folders, but they cannot have keys nor folders. [PERIOD] Instead .....
## Change the *provider's engine*. | ||
|
||
For example, let's say I have downloaded the *rethinkdb* provider and I want to work with it, then we go to your main script file (`app.js`, `bot.js`..., wherever you declare the new Klasa.Client), and write the following code: | ||
Now... how we update it? Go to your main file, where {@link KlasaClient} is initialized, and add a new option to your {@link KlasaClientOptions}. The following code snippet as an example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now... how do we update it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing 👍
With the last commit, I could not find any other bug. Feel free to test more the latest changes, it should be working perfectly now. |
Description of the PR
This PR aims to overhaul SettingGateway v2 to improve user intuitiveness and the experience of developers when they use said system.This PR went very far and with the breaking changes, I'm happy to announce SettingGateway v2.1, much more powerful and easier to use than the former, SettingGateway v2. New guides for this system are available in the docs.
TODO
ConfigUpdateEntryMany
(consistency).Replaced toSchemaFolder#getList
review.Configuration#list
Changes Proposed in this Pull Request (List new items in CHANGELOG.MD)
Added:
Configuration#reset(string[]);
to reset multiple keys.util.arraysEqual
.Symbol.iterator
to Schedule.Gateway#toJSON()
andGatewayDriver#toJSON()
.GatewayDriver#register
to be able to register new gateways without events (directly in yourapp.js
).util.getIdentifier
as a replacement for the function validator.SchemaFolder#keys()
,SchemaFolder#values()
,SchemaFolder#entries()
andSchemaFolder#[@@iterator]()
. Identical to Map's respective methods.Changed:
GatewayDriver#types
fromstring[]
toSet<string>
.SchemaPiece#modify()
toSchemaPiece#edit()
.Gateway#getKeys()
andGateway#getValues()
toGateway#keys(true)
andGateway#values(true)
respectively, which return iterators.Removed:
SchemaFolder#addKey
andSchemaFolder#addFolder
in favor to a more consistentSchema#add
.Configuration#resetConfiguration()
.Configuration#type
.SchemaFolder#removeKey
andSchemaFolder#removeFolder
in favor to a more consistentSchema#remove
.SchemaFolder#getList
and replaced it toConfiguration#list
.ConfigUpdateEntryMany
typedef in favor of a more constant type.SchemaFolder#keys
(Map<string>
) to reduce RAM usage and key caching duplication.Fixed:
Util.deepClone
not cloning full objects.SchemaFolder#_shardSyncSchema
not passing the action as string.null
values in updateMany's pattern not updating nested keys plus individual queries.configEntryCreate
when the entry does not exist.Configuration._patch
not patching after the second nested folder.Semver Classification