Skip to content
Merged

v3 #49

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
'parserOptions': {
'ecmaVersion': 12
},
'ignorePatterns': ['.eslintrc.js', 'docs/', 'gen-doc/'],
'ignorePatterns': ['.eslintrc.js', 'docs/', 'gen-doc/', 'science.js'],
'rules': {
'no-unused-vars': 'error',
'accessor-pairs': 'error',
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,28 @@

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

## v3.0.0

* Dropped support for message commands
* Module-Database-Models now always get loaded, even if module is not enabled (this allows to enable/disable modules on the fly)
* Database-Models can not be nested (because no one did that)
* CLI-Commands, Application-Commands, Events and other relevant data will now always get loaded, even if the module is
not enabled (this allows to enable/disable modules on the fly)
* Every time an event or CLI-Command gets executed, the bot will check if that module is enabled and will return if not
* Every time application commands need to get synced, the bot will check if the corresponding module is enabled.
[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.
* Errors in module configuration will only disable the module, not stop the bot.
* 💡 Errors in the built-in-configuration will still shut down the bot
* Module-Configuration will now only be generated on startup, not if configuration gets reloaded
* Added `disableModule` to helpers.js
* Improved `embedType` function
* `asyncForEach` is now deprecated, will be removed in v3.1.0
* Performance: To reduce the number of event listeners on `command`, every event used by every module will only once register an
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.


## v2.1.0

* Added new concept of localization
* Updated modules to the newest version, including new features, localization and bug-fixes
* Introduced new helper-functions and database-schemes (including channelLock, DatabaseSchemeVerison)
Expand Down
65 changes: 21 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ Please read the full [license](LICENSE). This is not legal advice.

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

## Please read this issue before continuing.

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

### Table of contents

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

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

### Features

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

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

#### Rules for modules
Expand All @@ -122,34 +128,31 @@ Every module should
* create as few commands as possible (we have a limit to 100 commands in total), so please try to
use [Sub-Commands](https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups)
wherever possible (eg: instead of having /ban, /kick, /mute etc, have a /moderate command with sub-commands)
* Use the newest features of the discord api and discord.js (buttons, selects, auto-complete, etc) if possible
* 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)
* Use the newest features of the discord api and discord.js (buttons, selects, etc) if possible
* process only needed user information and data
* follow our [terms of service](https://sc-net.work/tos), [Discord's Terms of Service](https://discord.com/tos) and
the [Discord Developer Terms of Service](https://discord.com/developers/docs/legal). A module should not allow users
to bypass or break the mentioned documents. This includes but is not limited to Nitro-Only-Features.
* should support [localization](#localization) fully, it's enough to translate to english, our volunteers are happy to translate it to german

#### module.json

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

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

#### Interaction-Command

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

#### Message-Command

A message-command file has to export the following things:

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

#### Events

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

An example config file should include the following things:

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

#### Helper-Functions

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

#### Localization

We support localization for multiple languages. Developers can use `localize(moduleName, StringName, {replaceOption: replaceOptionValue}` to
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
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.

#### Localization in configuration files
It's stupidly easy - you just put the locale string after the key, for example:
The key `description` becomes `description-en` to localize in the english language.
Fallback-Patern: `description-[userLanguage]` -> `description-en` -> `description`, which means that
you don't have to change anything ^^

© Simon Csaba, 2020-2022 (wow that's long)
© Simon Csaba, 2020-2021

Love ya <3
15 changes: 9 additions & 6 deletions default-locales.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"startup-info": "CustomBot v2 (https://github.com/SCNetwork/CustomDCBot) - Log-Level: %l",
"missing-moduleconf": "Missing moduleConfig-file. Automatically disabling all modules and overwriting modules.json later",
"sync-db": "Synced database",
"login-error": "Bot could not log in. Please try updating your token and restarting your bot.",
"not-invited": "Please invite the bot to your guild before continuing: %inv",
"login-error": "Bot could not log in. Error: %e",
"login-error-token": "Bot could not log in because the provided token is invalid. Please update your token.",
"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",
"logged-in": "Bot logged in as %tag and is now online.",
"logchannel-wrong-type": "There is no Log-Channel set or it has the wrong type (only text-channels are supported).",
"config-check-failed": "Configuration-Check failed. You can find more information in your log. The bot exited.",
Expand All @@ -26,22 +27,24 @@
"loaded-cli": "Loaded API-Action %c in %p",
"channel-lock": "Locked channel",
"channel-unlock": "Unlocked channel",
"channel-unlock-data-not-found": "Unlocking channel with ID %c failed because it was never locked (which is weird to beginn with)."
"channel-unlock-data-not-found": "Unlocking channel with ID %c failed because it was never locked (which is weird to beginn with).",
"module-disable": "Module %m got disabled because %r",
"migrate-success": "Migration from %o to %m finished successfully."
},
"reload": {
"reloading-config": "Reloading configuration...",
"reloading-config-with-name": "User %tag is reloading the configuration...",
"reloaded-config": "Configuration reloaded successfully.",
"reloaded-config": "Configuration reloaded successfully.\nOut of %totalModules modules, %enabled were enabled, %configDisabled were disabled because their configuration was wrong.",
"reload-failed": "Configuration reloaded failed. Bot shutting down.",
"reload-successful-syncing-commands": "Configuration reloaded successfully, syncing commands, to make sure permissions are up-to-date...",
"reload-failed-message": "**FAILED**\n```%r```\n**Please read your log to find more information**\nThe bot will kill itself now, bye :wave:",
"command-description": "Reloads the configuration"
},
"config": {
"checking-config": "Checking configurations...",
"done-with-checking": "Done with checking.",
"done-with-checking": "Done with checking. Out of %totalModules modules, %enabled were enabled, %configDisabled were disabled because their configuration was wrong.",
"creating-file": "Config %m/%f does not exist - I'm going to create it, please stand by...",
"checking-of-field-failed": "An error occurred while checking the content of field %fieldName in %m/$f",
"checking-of-field-failed": "An error occurred while checking the content of field \"%fieldName\" in %m/%f",
"saved-file": "Configuration-File %f in %m was saved successfully.",
"moduleconf-regeneration": "Regenerating module configuration, no settings will be overwritten, don't worry.",
"moduleconf-regeneration-success": "Module configuration regeneration successfully finished.",
Expand Down
Loading