From dc2f307ca720f3ac7ebd975be1102e4153c674fe Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 6 Oct 2022 19:09:21 +0200 Subject: [PATCH 01/10] docs(config-files): support for `content.elementToggle` feature --- CHANGELOG.md | 3 +++ README.md | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a26ddc6..fb229930 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ This changelog contains mostly API-Changes and changes for developers. +## v3.6.1 +* Support for configuration-example-file `content.elementToggle` toggle to improve UX in the SCNX Dashboard + ## v3.5.0 * Like ten new previously closed-sourced-modules got added * Locales-Loading now takes place in splitted files, instead of a big `default-locales.json` diff --git a/README.md b/README.md index 6d4da95d..c0301134 100644 --- a/README.md +++ b/README.md @@ -300,7 +300,8 @@ An example config file should include the following things: * `isImage`: If true, users will be able to set this parameter as Image, Author-Icon, Footer-Icon or Thumbnail of an embed (only if `allowEmbed` is enabled) * `allowNull` (default: `false`, optional): If the value of this field can be empty - * `disableKeyEdits` (if type === `keyed`): If enabled the user is not allowed to change the keys of this element + * `disableKeyEdits` (if type === `keyed`): If enabled the user can not edit the keys of the object + * `elementToggle` (if type === `boolean`): If this option gets turned of, other fields of the config-element / file will not be rendered in the dashboard #### `botReady`-Event and Config-Reload From e3c920be06a2b1f61187f2f6e2f7f7b3717f586a Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 6 Oct 2022 19:20:38 +0200 Subject: [PATCH 02/10] feat(moderation): support for elementToggle --- modules/moderation/configs/antiJoinRaid.json | 5 +++-- modules/moderation/configs/antiSpam.json | 5 +++-- modules/moderation/configs/joinGate.json | 5 +++-- modules/moderation/configs/verification.json | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/moderation/configs/antiJoinRaid.json b/modules/moderation/configs/antiJoinRaid.json index e774b210..3366bcf1 100644 --- a/modules/moderation/configs/antiJoinRaid.json +++ b/modules/moderation/configs/antiJoinRaid.json @@ -9,7 +9,8 @@ "humanname-de": "Aktiviert", "description-de": "Aktiviert oder deaktiviert das Anti-Join-Raid-System", "params-de": {}, - "default-de": true + "default-de": true, + "elementToggle": true }, { "field_name": "timeframe", @@ -69,4 +70,4 @@ "default-de": true } ] -} +} \ No newline at end of file diff --git a/modules/moderation/configs/antiSpam.json b/modules/moderation/configs/antiSpam.json index 1dc78c7d..e93d6c8e 100644 --- a/modules/moderation/configs/antiSpam.json +++ b/modules/moderation/configs/antiSpam.json @@ -9,7 +9,8 @@ "humanname-de": "Aktiviert", "description-de": "Aktiviert oder deaktiviert das Anti-Spam-System", "params-de": {}, - "default-de": true + "default-de": true, + "elementToggle": true }, { "field_name": "timeframe", @@ -140,4 +141,4 @@ "default-de": [] } ] -} +} \ No newline at end of file diff --git a/modules/moderation/configs/joinGate.json b/modules/moderation/configs/joinGate.json index 6dd5d05d..00c0b693 100644 --- a/modules/moderation/configs/joinGate.json +++ b/modules/moderation/configs/joinGate.json @@ -9,7 +9,8 @@ "humanname-de": "Aktiviert?", "description-de": "Aktiviere oder deaktiviere das Join-Gate", "params-de": {}, - "default-de": true + "default-de": true, + "elementToggle": true }, { "field_name": "allUsers", @@ -89,4 +90,4 @@ "default-de": true } ] -} +} \ No newline at end of file diff --git a/modules/moderation/configs/verification.json b/modules/moderation/configs/verification.json index eb4f2a17..55b7976e 100644 --- a/modules/moderation/configs/verification.json +++ b/modules/moderation/configs/verification.json @@ -9,7 +9,8 @@ "humanname-de": "", "description-de": "", "params-de": {}, - "default-de": false + "default-de": false, + "elementToggle": true }, { "field_name": "verification-needed-role", @@ -141,4 +142,4 @@ "default-de": "Welcome! I have send you a DM about your verification-process. Please read it carefully. If you have DMs disabled, please activate them and click the button below. This step is required to join this server." } ] -} +} \ No newline at end of file From c449cbe46fd9e9a28de1cc5432556cd7b862fe79 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 7 Oct 2022 20:07:02 +0200 Subject: [PATCH 03/10] docs(config-files): support for `content.dependsOn` feature --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c0301134..3f801ef3 100644 --- a/README.md +++ b/README.md @@ -301,7 +301,8 @@ An example config file should include the following things: of an embed (only if `allowEmbed` is enabled) * `allowNull` (default: `false`, optional): If the value of this field can be empty * `disableKeyEdits` (if type === `keyed`): If enabled the user can not edit the keys of the object - * `elementToggle` (if type === `boolean`): If this option gets turned of, other fields of the config-element / file will not be rendered in the dashboard + * `elementToggle` (if type === `boolean`): If this option gets turned off, other fields of the config-element / file will not be rendered in the dashboard + * `dependsOn` (a name of any (other) boolean-field): If the referenced boolean field (the value of this option should be equal to the `field.field_name` of a boolean field) is turned off, the field will be not be rendered in the dashboard #### `botReady`-Event and Config-Reload From 6fbe05de8a164a3e23991e765c828c44fa9e2f92 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 7 Oct 2022 20:09:21 +0200 Subject: [PATCH 04/10] feat(tickets): make uses of new `dependsOn` field --- modules/tickets/config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/tickets/config.json b/modules/tickets/config.json index 5b371093..ecd52978 100644 --- a/modules/tickets/config.json +++ b/modules/tickets/config.json @@ -93,6 +93,7 @@ "allowEmbed": true, "description-de": "Diese Nachricht wird an den Nutzer gesendet, wenn die entsprechende Option aktiviert ist", "description-en": "This message gets send to the user if sendUserDMAfterTicketClose is enabled", + "dependsOn": "sendUserDMAfterTicketClose", "params-de": [ { "name": "%transcriptURL%", From ce3efdc9d817eed4500d35ff48eb353c9f449b5f Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 10 Oct 2022 14:53:56 +0200 Subject: [PATCH 05/10] feat(config): support for userID field --- README.md | 16 +++++++++++----- locales/de.json | 3 ++- locales/en.json | 1 + src/functions/configuration.js | 9 ++++++++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3f801ef3..279e2bca 100644 --- a/README.md +++ b/README.md @@ -39,13 +39,18 @@ information about that in [this issue](https://github.com/SCNetwork/CustomDCBot/ 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) -, [get a membership](https://membership.sc-network.net) (also on [Patreon](https://patreon.com/scnetwork)), or donate [via Creditcard](https://scnx.app/scam) or [PayPal](https://paypal.me/therealscderox). Thank you so much <3 +, [get a membership](https://membership.sc-network.net) (also on [Patreon](https://patreon.com/scnetwork)), or +donate [via Creditcard](https://scnx.app/scam) or [PayPal](https://paypal.me/therealscderox). Thank you so much <3 ## Need help? -Are you stuck? Please do not ask on our Discord (unless you are using our hosted version), instead ask in the [discussions-tab](https://github.com/SCNetwork/CustomDCBot/discussions). + +Are you stuck? Please do not ask on our Discord (unless you are using our hosted version), instead ask in +the [discussions-tab](https://github.com/SCNetwork/CustomDCBot/discussions). ## Need something even more custom? -We are happy to give you a quote for individual requirements. Please email `sales@sc-network.net` with your requirements. + +We are happy to give you a quote for individual requirements. Please email `sales@sc-network.net` with your +requirements. ### Table of contents @@ -207,7 +212,8 @@ An interaction-command ("slash command") file has to export the following things * `description`: Description of the command * `restricted`: Can this command only be run one of the bot operators (e.g. config reloading, change status or ..., boolean) - * `defaultPermission`: Boolean (default: true): If enabled everyone on the guild can use this command and your command's permissions can not be synced + * `defaultPermission`: Boolean (default: true): If enabled everyone on the guild can use this command and your + command's permissions can not be synced * `options`: * [ApplicationCommandOptionData](https://discord.js.org/#/docs/main/stable/typedef/ApplicationCommandOptionData) OR @@ -272,7 +278,7 @@ An example config file should include the following things: * `field_name`: Name of the config field * `default-`: Default value of this field (replace `` with a supported language code), Fallback-Order: `default-`, `default-en`, `default` - * `type`: Can be `channelID`, `select`, `timezone` (treated as string, please check validity before using), `roleID` + * `type`: Can be `channelID`, `userID`, `select`, `timezone` (treated as string, please check validity before using), `roleID` , `boolean`, `integer`, `array`, `keyed` (codename for an JS-Object) or `string` * `description-`: Description of this field (replace `` with a supported language code), diff --git a/locales/de.json b/locales/de.json index 04c2668e..e654f8b5 100644 --- a/locales/de.json +++ b/locales/de.json @@ -66,6 +66,7 @@ "moduleconf-regeneration": "Modul-Konfiguration wird regeniert, es werden keine Einstellungen überschrieben.", "moduleconf-regeneration-success": "Module-Konfiguration wurde regeniert.", "channel-not-found": "Kanal mit ID \"%id\" wurde nicht gefunden", + "user-not-found": "Discord-Account mit ID \"%id\" wurde nicht gefunden", "channel-not-on-guild": "Kanal mit ID \"%id\" ist nicht auf deinem Server", "role-not-found": "Rolle mit ID \"%id\" wurde nicht auf deinem Server gefunden", "config-reload": "Gesamte Konfiguration wird neugeladen...", @@ -827,4 +828,4 @@ "remove-subcommand-description": "Entferne deine Custom Rolle", "confirm-option-remove-description": "Willst du deine Custom Rolle wirklich löschen? Dies wird keine laufenden Cooldowns zurücksetzen" } -} +} \ No newline at end of file diff --git a/locales/en.json b/locales/en.json index 48b54b61..bb60272b 100644 --- a/locales/en.json +++ b/locales/en.json @@ -64,6 +64,7 @@ "moduleconf-regeneration": "Regenerating module configuration, no settings will be overwritten, don't worry.", "moduleconf-regeneration-success": "Module configuration regeneration successfully finished.", "channel-not-found": "Channel with ID \"%id\" could not be found", + "user-not-found": "Discord-User with ID \"%id\" could not be found", "channel-not-on-guild": "Channel with ID \"%id\" is not on your guild", "channel-invalid-type": "Channel with ID \"%id\" has a type that can not be used for this field", "role-not-found": "Role with ID \"%id\" could not be found on your guild", diff --git a/src/functions/configuration.js b/src/functions/configuration.js index e5cfd9aa..479cdd13 100644 --- a/src/functions/configuration.js +++ b/src/functions/configuration.js @@ -160,7 +160,7 @@ async function checkModuleConfig(moduleName, afterCheckEventFile = null) { } if (field.disableKeyEdits) { for (const content in configElement[field.field_name]) { - if (!field.default[content]) { + if (typeof field.default[content] === 'undefined') { delete configElement[field.field_name][content]; ow = true; } @@ -294,6 +294,13 @@ async function checkType(type, value, contentFormat = null, allowEmbed = false) if (!errored) errored = !(await checkType(contentFormat, v, null, allowEmbed)); } return !errored; + case 'userID': + const user = await client.users.fetch(value).catch(() => {}); + if (!user) { + logger.error(localize('config', 'user-not-found', {id: value})); + return false; + } + return true; case 'channelID': const channel = await client.channels.fetch(value).catch(() => { }); From c35a6d226b3f54302f6af635807fb4017910e671 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 10 Oct 2022 15:23:38 +0200 Subject: [PATCH 06/10] feat(config): support for imgURL field type --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 279e2bca..75344cd8 100644 --- a/README.md +++ b/README.md @@ -278,7 +278,7 @@ An example config file should include the following things: * `field_name`: Name of the config field * `default-`: Default value of this field (replace `` with a supported language code), Fallback-Order: `default-`, `default-en`, `default` - * `type`: Can be `channelID`, `userID`, `select`, `timezone` (treated as string, please check validity before using), `roleID` + * `type`: Can be `channelID`, `userID`, `imgURL`, `select`, `timezone` (treated as string, please check validity before using), `roleID` , `boolean`, `integer`, `array`, `keyed` (codename for an JS-Object) or `string` * `description-`: Description of this field (replace `` with a supported language code), From 35662db66f876299f2fd6ab40e78670fe2aa86a4 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 10 Oct 2022 15:36:30 +0200 Subject: [PATCH 07/10] feat(fun): make use of new imgURL type --- modules/fun/config.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/fun/config.json b/modules/fun/config.json index 5ea53134..660c07fd 100644 --- a/modules/fun/config.json +++ b/modules/fun/config.json @@ -132,7 +132,7 @@ "https://media1.tenor.com/images/fd47e55dfb49ae1d39675d6eff34a729/tenor.gif?itemid=12687187" ], "type": "array", - "content": "string", + "content": "imgURL", "humanname-de": "Umarmungsbilder", "description-de": "Bilder aus welchen, wenn jemand /hug ausführt, zufällig ausgewählt wird", "params-de": {}, @@ -189,7 +189,7 @@ "https://media1.tenor.com/images/78095c007974aceb72b91aeb7ee54a71/tenor.gif?itemid=5095865" ], "type": "array", - "content": "string", + "content": "imgURL", "humanname-de": "Kussbilder", "description-de": "Bilder aus welchen, wenn jemand /kiss ausführt, zufällig ausgewählt wird", "params-de": {}, @@ -248,7 +248,7 @@ "https://media1.tenor.com/images/03ea2379718496fbbd144c5bc50f8e96/tenor.gif?itemid=18908545" ], "type": "array", - "content": "string", + "content": "imgURL", "humanname-de": "Schlag-Bilder", "description-de": "Bilder aus welchen, wenn jemand /slap ausführt, zufällig ausgewählt wird", "params-de": {}, @@ -308,7 +308,7 @@ "https://media1.tenor.com/images/be0c22e0af951aa7fa8753381663eb2c/tenor.gif?itemid=15824856" ], "type": "array", - "content": "string", + "content": "imgURL", "humanname-de": "Tätschel-Bilder", "description-de": "Bilder aus welchen, wenn jemand /pat ausführt, zufällig ausgewählt wird", "params-de": {}, From 200cf368e68ecfa23504bcb00ce00b031b644fba Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 10 Oct 2022 18:56:18 +0200 Subject: [PATCH 08/10] fix(fun): imgURL type causes crash --- src/functions/configuration.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/functions/configuration.js b/src/functions/configuration.js index 479cdd13..62c66c76 100644 --- a/src/functions/configuration.js +++ b/src/functions/configuration.js @@ -284,6 +284,7 @@ async function checkType(type, value, contentFormat = null, allowEmbed = false) if (parseInt(value) === 0) return true; return !!parseInt(value); case 'string': + case 'imgURL': case 'timezone': // Timezones can not be checked correctly for their type currently. if (allowEmbed && typeof value === 'object') return true; return typeof value === 'string'; From cf29013b4e39d0745142368959ce29a1c4db210a Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 11 Oct 2022 12:17:35 +0200 Subject: [PATCH 09/10] fix(config): not overwriting if field is missing --- src/functions/configuration.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/functions/configuration.js b/src/functions/configuration.js index 62c66c76..d8a93c26 100644 --- a/src/functions/configuration.js +++ b/src/functions/configuration.js @@ -129,6 +129,7 @@ async function checkModuleConfig(moduleName, afterCheckEventFile = null) { } if (typeof configElement[field.field_name] === 'undefined') { configElement[field.field_name] = field.default; + ow = true; return res(configElement); } else if (field.type === 'keyed' && field.disableKeyEdits) { for (const key in field.default) { From 6099af7d154424a1a285231d886404d04ae00006 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 11 Oct 2022 13:04:19 +0200 Subject: [PATCH 10/10] feat: version v3.6.0 --- CHANGELOG.md | 8 ++++++-- package.json | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb229930..2b5c1466 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,12 @@ This changelog contains mostly API-Changes and changes for developers. -## v3.6.1 -* Support for configuration-example-file `content.elementToggle` toggle to improve UX in the SCNX Dashboard +## v3.6.0 +* Support for configuration-example-file `content.elementToggle` toggle to improve UX in the SCNX Dashboard ([#76](https://github.com/SCNetwork/CustomDCBot/pull/76)) +* Support for configuration-example-file `content.dependsOn` toggle to improve UX in the SCNX Dashboard ([#76](https://github.com/SCNetwork/CustomDCBot/pull/76)) +* Support for new field-types: `userID`, `imgURL` ([#76](https://github.com/SCNetwork/CustomDCBot/pull/76)) +* Moderation-Modul: Support for Channel-Mutes ([#77](https://github.com/SCNetwork/CustomDCBot/pull/77)) +* Channel-Stats-Modul: Support for userWithRole parameters ([#78](https://github.com/SCNetwork/CustomDCBot/pull/78)) ## v3.5.0 * Like ten new previously closed-sourced-modules got added diff --git a/package.json b/package.json index 95c3f0b7..5df49ba4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "customdcbot", - "version": "3.5.1", + "version": "3.6.0", "description": "Create your own discord bot - Fully customizable and with a lot of features", "main": "main.js", "repository": {