Skip to content

Commit c407371

Browse files
authored
v3 (#49)
* feat: prepared for v3 * style: fixed incorrect code-style in configuration.js * docs: fixed wrong documentation syntax
1 parent b9e90d9 commit c407371

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1120
-640
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
'parserOptions': {
88
'ecmaVersion': 12
99
},
10-
'ignorePatterns': ['.eslintrc.js', 'docs/', 'gen-doc/'],
10+
'ignorePatterns': ['.eslintrc.js', 'docs/', 'gen-doc/', 'science.js'],
1111
'rules': {
1212
'no-unused-vars': 'error',
1313
'accessor-pairs': 'error',

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,28 @@
22

33
This changelog contains mostly API-Changes and changes for developers.
44

5+
## v3.0.0
6+
7+
* Dropped support for message commands
8+
* Module-Database-Models now always get loaded, even if module is not enabled (this allows to enable/disable modules on the fly)
9+
* Database-Models can not be nested (because no one did that)
10+
* CLI-Commands, Application-Commands, Events and other relevant data will now always get loaded, even if the module is
11+
not enabled (this allows to enable/disable modules on the fly)
12+
* Every time an event or CLI-Command gets executed, the bot will check if that module is enabled and will return if not
13+
* Every time application commands need to get synced, the bot will check if the corresponding module is enabled.
14+
[To ensure the safe performance of all authorized activities](https://soundcloud.com/gamequotes/glados-to-ensure-the-safe), this check will also get executed when a command gets executed.
15+
* Errors in module configuration will only disable the module, not stop the bot.
16+
* 💡 Errors in the built-in-configuration will still shut down the bot
17+
* Module-Configuration will now only be generated on startup, not if configuration gets reloaded
18+
* Added `disableModule` to helpers.js
19+
* Improved `embedType` function
20+
* `asyncForEach` is now deprecated, will be removed in v3.1.0
21+
* Performance: To reduce the number of event listeners on `command`, every event used by every module will only once register an
22+
event listener. When an event gets invoked, the bot will run every registered module-event. To ensure fast reaction-times, this will get done synchronously.
23+
24+
525
## v2.1.0
26+
627
* Added new concept of localization
728
* Updated modules to the newest version, including new features, localization and bug-fixes
829
* Introduced new helper-functions and database-schemes (including channelLock, DatabaseSchemeVerison)

README.md

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ Please read the full [license](LICENSE). This is not legal advice.
3535

3636
As mentioned above our business model is to host these bots for servers - it does not really make sense to publish our
3737
product here - but we do it anyway - but we need your support! Feel free to [contribute](.github/CONTRIBUTING.md)
38-
, [donate on Patreon](https://patreon.com/scnetwork), [subscribe to a membership](https://membership.sc-network.net),
38+
, [donate on Patreon](https://patreon.com/scnetwork)
3939
or on [any other platform](https://github.com/SCNetwork/CustomDCBot?sponsor=1). Thank you so much <3
4040

4141
## Please read this issue before continuing.
4242

43-
This repo does not get any new modules, but will get updates regarding core-functionality. [Learn more](https://github.com/SCNetwork/CustomDCBot/issues/13).
43+
This repo does not get any new modules or features
44+
currently. [Learn more](https://github.com/SCNetwork/CustomDCBot/issues/13).
4445

4546
### Table of contents
4647

@@ -60,6 +61,11 @@ This repo does not get any new modules, but will get updates regarding core-func
6061
6. The bot is now generating a `modules.json` and a `strings.json` file inside your `config` directory. You
6162
can [change](#configuration) them.
6263

64+
When reading thought the code, you may encounter code "tracking" parts of the bot.
65+
This part is only enabled in the SCNX-Version (and users can opt-out there if the want to).
66+
This open-source-version won't contact SCNX, SC Network and won't share any information with us, don't worry. You
67+
can verify this by looking at the source code, [science.js](src/functions/science.js) looks like a great start-point.
68+
6369
### Features
6470

6571
* Everything is split in different [modules](#modules) - you can enable, configure and disable it how you want
@@ -108,7 +114,7 @@ Please read the license for more information.
108114

109115
**Before you make a module**: Please create an issue with your suggestion and claim that you are working on it so nobody
110116
is working on the same thing (;\
111-
Also please read the [Rules for modules](#rules-for-modules).\
117+
Also please read the [Rues for modules](#rules-for-modules).\
112118
**Submit a module**: Simply create a pullrequest, and we will check your module and merge it then (;
113119

114120
#### Rules for modules
@@ -122,34 +128,31 @@ Every module should
122128
* create as few commands as possible (we have a limit to 100 commands in total), so please try to
123129
use [Sub-Commands](https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups)
124130
wherever possible (eg: instead of having /ban, /kick, /mute etc, have a /moderate command with sub-commands)
125-
* Use the newest features of the discord api and discord.js (buttons, selects, auto-complete, etc) if possible
126-
* process and save only needed user information and data. If sensitive data (for example message content) gets stored (should not be needed), it has to be encrypted according to [Discord'S Developers Terms of Service](https://discord.com/developers/docs/legal)
131+
* Use the newest features of the discord api and discord.js (buttons, selects, etc) if possible
132+
* process only needed user information and data
127133
* follow our [terms of service](https://sc-net.work/tos), [Discord's Terms of Service](https://discord.com/tos) and
128134
the [Discord Developer Terms of Service](https://discord.com/developers/docs/legal). A module should not allow users
129135
to bypass or break the mentioned documents. This includes but is not limited to Nitro-Only-Features.
130-
* should support [localization](#localization) fully, it's enough to translate to english, our volunteers are happy to translate it to german
131136

132137
#### module.json
133138

134139
Every module has to contain a `module.json` file with the following content:
135140

136141
* `name` of the module. Should be the same as the name of your dictionary.
137-
* `humanReadableName`: Name shown to users (Supports [localization](#localization-in-configuration-files))
138142
* `author`
139143
* `name`: Name of the author
140144
* `link`: Link to the author
141-
* `description`: Short description of the module (Supports [localization](#localization-in-configuration-files))
145+
* `description`: Short description of the module
142146
* `cli` (optional): [CLI-File](#cli-files) of your module
143147
* `commands-dir` (optional): Directory inside your module folder where all
144148
the [interaction-command-files](#interaction-command) are in
145-
* `message-commands-dir` (optional, not recommended if not necessary): Directory inside your module folder where all
146-
the [message-command-files](#message-command) are in
147149
* `on-load-event` (optional): File with exported `onLoad` function in it. Gets executed when your commands got loaded
148150
successfully; at this point the Client is not logged in yet, so you can't communicate with Discord (yet).
149151
* `events-dir` (optional): Directory inside your module folder where all the [event-files](#events) are in
150152
* `models-dir` (optional): Directory inside your module folder where all the models-files are in
151153
* `config-example-files` (optional, seriously leave this out when you don't have config files): Array
152154
of [config-files](#example-config-file) inside your module directory.
155+
* `tags` (optional): Array of tags.
153156

154157
#### Interaction-Command
155158

@@ -186,19 +189,8 @@ An interaction-command ("slash command") file has to export the following things
186189

187190
#### Message-Command
188191

189-
A message-command file has to export the following things:
190-
191-
* `run`: Function that gets triggered if the command gets executed (provided arguments: `client` (discord.js Client)
192-
, `msg` (MessageObject),
193-
`args` (Array of arguments))
194-
* `help`
195-
* `name`: Name of the command (should be the same name as the file name)
196-
* `description`: Description of the command
197-
* `aliases`: Array of all aliases. Should contain the value of `name`.
198-
* `config`
199-
* `args`: How many arguments does this command *at least* need?
200-
* `restricted`: Can this command only be run one of the bot operators (e.g. config reloading, change status or ...,
201-
boolean)
192+
Starting V3, message-commands are no longer supported. Please use [Interaction-Commands](#interaction-command)
193+
instead. Read more in [CHANGELOG.md](CHANGELOG.md).
202194

203195
#### Events
204196

@@ -227,26 +219,23 @@ Note: All you CLI-Commands can also get executed via the API.
227219

228220
An example config file should include the following things:
229221

230-
* `filename`: Name of the generated config file
231-
* `humanname`: Name shown to users of the configuration file (Supports [localization](#localization-in-configuration-files))
232-
* `description`: Description of the configuration file (Supports [localization](#localization-in-configuration-files))
222+
* `filename`: Name of the generated config file
233223
* `configElements` (boolean, default: false): If enabled the configuration-file will be an array of an object of the
234224
content-fields
235225
* `content`: Array of content fields:
236226
* `field_name`: Name of the config field
237-
* `humanname`: Name of the configuration field, shown to users (Supports [localization](#localization-in-configuration-files))
238-
* `default`: Default value (Supports [localization](#localization-in-configuration-files))
227+
* `default`: Default value
239228
* `type`: Can be `channelID`, `select`, `roleID`, `boolean`, `integer`, `array`, `keyed` (codename for an JS-Object)
240229
or `string`
241-
* `description`: Short description of this field (Supports [localization](#localization-in-configuration-files))
230+
* `description`: Short description of this field
242231
* `allowEmbed` (if type === `array, keyed or string`): Allow the usage of an [embed](#configuration) (Note: Please
243232
use the build-in function in `src/functions/helpers.js`)
244233
* `content` (if type === `array`): Type (see `type` above) of every value
245234
* `content` (if type === `select`): Array of the possible options
246235
* `content` (if type === `keyed`):
247236
* `key`: Type (see `type` above) of the index of every value
248237
* `value`: Type (see `type` above) of the value of every value
249-
* `params` (if type === `string`, array, optional, Supports [localization](#localization-in-configuration-files))
238+
* `params` (if type === `string`, array, optional)
250239
* `name`: Name of the parameter (e.g. `%mention%`)
251240
* `description`: Description of the parameter (e.g. `Mention of the user`)
252241
* `fieldValue` (only if type === `select`): If set, the parameter can only be used if the value of the field
@@ -264,21 +253,9 @@ please push the return value to `client.intervals` to get them removed on `confi
264253

265254
#### Helper-Functions
266255

267-
The bot includes a lot of functions to make your live easier. Please open
256+
The bot includes a lot of functions to make your live easier. Please open
268257
the [DevDoc](https://custombot-devdocs.sc-network.net/) to see all of them.
269258

270-
#### Localization
271-
272-
We support localization for multiple languages. Developers can use `localize(moduleName, StringName, {replaceOption: replaceOptionValue}` to
273-
use localized value, to add new strings, add it under the language key (we only publish the english translation at the moment, so `en`) and
274-
under the module- / part-name. Please see [Localization in configuration files](#localization-in-configuration-files) to learn about localization in configuration files - I promise, it's stupidly easy.
275-
276-
#### Localization in configuration files
277-
It's stupidly easy - you just put the locale string after the key, for example:
278-
The key `description` becomes `description-en` to localize in the english language.
279-
Fallback-Patern: `description-[userLanguage]` -> `description-en` -> `description`, which means that
280-
you don't have to change anything ^^
281-
282-
© Simon Csaba, 2020-2022 (wow that's long)
259+
© Simon Csaba, 2020-2021
283260

284261
Love ya <3

default-locales.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"startup-info": "CustomBot v2 (https://github.com/SCNetwork/CustomDCBot) - Log-Level: %l",
55
"missing-moduleconf": "Missing moduleConfig-file. Automatically disabling all modules and overwriting modules.json later",
66
"sync-db": "Synced database",
7-
"login-error": "Bot could not log in. Please try updating your token and restarting your bot.",
8-
"not-invited": "Please invite the bot to your guild before continuing: %inv",
7+
"login-error": "Bot could not log in. Error: %e",
8+
"login-error-token": "Bot could not log in because the provided token is invalid. Please update your token.",
9+
"login-error-intents": "Bot could not log in because the intents were not enabled correctly. Please enable \"PRESENCE INTENT\", \"SERVER MEMBERS INTENT\" and \"MESSAGE CONTENT INTENT\" in your Discord-Developer-Dashboard: %url", "not-invited": "Please invite the bot to your guild before continuing: %inv",
910
"logged-in": "Bot logged in as %tag and is now online.",
1011
"logchannel-wrong-type": "There is no Log-Channel set or it has the wrong type (only text-channels are supported).",
1112
"config-check-failed": "Configuration-Check failed. You can find more information in your log. The bot exited.",
@@ -26,22 +27,24 @@
2627
"loaded-cli": "Loaded API-Action %c in %p",
2728
"channel-lock": "Locked channel",
2829
"channel-unlock": "Unlocked channel",
29-
"channel-unlock-data-not-found": "Unlocking channel with ID %c failed because it was never locked (which is weird to beginn with)."
30+
"channel-unlock-data-not-found": "Unlocking channel with ID %c failed because it was never locked (which is weird to beginn with).",
31+
"module-disable": "Module %m got disabled because %r",
32+
"migrate-success": "Migration from %o to %m finished successfully."
3033
},
3134
"reload": {
3235
"reloading-config": "Reloading configuration...",
3336
"reloading-config-with-name": "User %tag is reloading the configuration...",
34-
"reloaded-config": "Configuration reloaded successfully.",
37+
"reloaded-config": "Configuration reloaded successfully.\nOut of %totalModules modules, %enabled were enabled, %configDisabled were disabled because their configuration was wrong.",
3538
"reload-failed": "Configuration reloaded failed. Bot shutting down.",
3639
"reload-successful-syncing-commands": "Configuration reloaded successfully, syncing commands, to make sure permissions are up-to-date...",
3740
"reload-failed-message": "**FAILED**\n```%r```\n**Please read your log to find more information**\nThe bot will kill itself now, bye :wave:",
3841
"command-description": "Reloads the configuration"
3942
},
4043
"config": {
4144
"checking-config": "Checking configurations...",
42-
"done-with-checking": "Done with checking.",
45+
"done-with-checking": "Done with checking. Out of %totalModules modules, %enabled were enabled, %configDisabled were disabled because their configuration was wrong.",
4346
"creating-file": "Config %m/%f does not exist - I'm going to create it, please stand by...",
44-
"checking-of-field-failed": "An error occurred while checking the content of field %fieldName in %m/$f",
47+
"checking-of-field-failed": "An error occurred while checking the content of field \"%fieldName\" in %m/%f",
4548
"saved-file": "Configuration-File %f in %m was saved successfully.",
4649
"moduleconf-regeneration": "Regenerating module configuration, no settings will be overwritten, don't worry.",
4750
"moduleconf-regeneration-success": "Module configuration regeneration successfully finished.",

0 commit comments

Comments
 (0)