From fa1258b9ea4b14473b7c65d3cc73e26db3b1ba0a Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Fri, 19 Aug 2022 15:52:57 +0300 Subject: [PATCH] clean up reset prompt --- .../en_gb/settings/en_gb_moderation.lang | 3 +++ .../settings/administration/IgnoreChannels.js | 3 +++ .../settings/administration/Protection.js | 3 +++ .../components/settings/logging/DmInfraction.js | 15 ++++++++++++--- .../components/settings/logging/Messages.js | 3 +++ .../components/settings/logging/Moderation.js | 15 ++++++++++++--- .../components/settings/moderation/Grantable.js | 3 +++ .../settings/moderation/InviteFilter.js | 3 +++ .../components/settings/moderation/LinkFilter.js | 3 +++ .../settings/moderation/MentionFilter.js | 3 +++ .../components/settings/moderation/WordFilter.js | 3 +++ .../components/settings/moderation/WordWatcher.js | 3 +++ .../components/settings/utility/Autorole.js | 3 +++ .../components/settings/utility/Selfrole.js | 4 ++++ .../components/settings/utility/StickyRole.js | 3 +++ 15 files changed, 64 insertions(+), 6 deletions(-) diff --git a/src/localization/en_gb/settings/en_gb_moderation.lang b/src/localization/en_gb/settings/en_gb_moderation.lang index 1f516fd..3b21c4f 100644 --- a/src/localization/en_gb/settings/en_gb_moderation.lang +++ b/src/localization/en_gb/settings/en_gb_moderation.lang @@ -26,6 +26,9 @@ Respond with what you want to **remove** from the **{list}** list. [SETTING_PROMPT_SET] Respond with what you want to **set** the **{list}** list to. +[SETTING_PROMPT_RESET] +Are you sure you want to reset the option? + // General filter stuff [SETTING_FILTER_ACTION_ADD] Successfully added a **{type}** action for {trigger} filter events. diff --git a/src/structure/components/settings/administration/IgnoreChannels.js b/src/structure/components/settings/administration/IgnoreChannels.js index 1cf7d58..565ee0a 100644 --- a/src/structure/components/settings/administration/IgnoreChannels.js +++ b/src/structure/components/settings/administration/IgnoreChannels.js @@ -55,6 +55,9 @@ class IgnoreSetting extends Setting { params: { list: list.value } }); if (response.error) return response; + if (method.value === 'reset' && !this.client.resolver.resolveBoolean(response)) { + return { index: 'SETTING_NO_CHANGE' }; + } const params = Util.parseQuotes(response).map(([param]) => param); let values = []; diff --git a/src/structure/components/settings/administration/Protection.js b/src/structure/components/settings/administration/Protection.js index 402e951..01f4859 100644 --- a/src/structure/components/settings/administration/Protection.js +++ b/src/structure/components/settings/administration/Protection.js @@ -69,6 +69,9 @@ class ProtectionSetting extends Setting { params: { list: 'roles' } }); if (response.error) return response; + if (roles.value === 'reset' && !this.client.resolver.resolveBoolean(response)) { + return { index: 'SETTING_NO_CHANGE' }; + } const { guild } = interaction; const params = Util.parseQuotes(response).map(([param]) => param); diff --git a/src/structure/components/settings/logging/DmInfraction.js b/src/structure/components/settings/logging/DmInfraction.js index 23f1970..db684a9 100644 --- a/src/structure/components/settings/logging/DmInfraction.js +++ b/src/structure/components/settings/logging/DmInfraction.js @@ -107,14 +107,23 @@ class DmInfraction extends Setting { if (anonymous) setting.anonymous = anonymous.value; if (infractions) { + const extra = `\n\n${interaction.format('SETTING_DMINFRACTION_VALID', { + valid: Infractions.join(`, `) + })}`; + const reset = infractions.value === 'reset'; const response = await this._prompt(interaction, { message: `${interaction.format(`SETTING_PROMPT_${infractions.value.toUpperCase()}`, { list: 'infractions' - })}\n\n${interaction.format('SETTING_DMINFRACTION_VALID', { - valid: Infractions.join(`, `) - })}` + })}${reset ? '' : extra}` }); if (response.error) return response; + if (reset) { + if (this.client.resolver.resolveBoolean(response)) { + setting.infractions = [...Infractions]; + return { index }; + } + return { index: 'SETTING_NO_CHANGE' }; + } const infs = response.split(' ') .map((inf) => this.client.resolver.resolveInfraction(inf)) diff --git a/src/structure/components/settings/logging/Messages.js b/src/structure/components/settings/logging/Messages.js index dbbb964..31e7949 100644 --- a/src/structure/components/settings/logging/Messages.js +++ b/src/structure/components/settings/logging/Messages.js @@ -114,6 +114,9 @@ class MessageLog extends Setting { time }); if (content.error) return content; + if (method.value === 'reset' && !this.client.resolver.resolveBoolean(content)) { + return { index: 'SETTING_NO_CHANGE' }; + } const words = Util.parseQuotes(content).map(([word]) => word); diff --git a/src/structure/components/settings/logging/Moderation.js b/src/structure/components/settings/logging/Moderation.js index 275ef84..68e445b 100644 --- a/src/structure/components/settings/logging/Moderation.js +++ b/src/structure/components/settings/logging/Moderation.js @@ -85,14 +85,23 @@ class ModerationLog extends Setting { if (enabled) setting.enabled = enabled.value; if (infractions) { + const extra = `\n\n${interaction.format('SETTING_DMINFRACTION_VALID', { + valid: Infractions.join(`, `) + })}`; + const reset = infractions.value === 'reset'; const response = await this._prompt(interaction, { message: `${interaction.format(`SETTING_PROMPT_${infractions.value.toUpperCase()}`, { list: 'infractions' - })}\n\n${interaction.format('SETTING_DMINFRACTION_VALID', { - valid: Infractions.join(`, `) - })}` + })}${reset ? '' : extra}` }); if (response.error) return response; + if (reset) { + if (this.client.resolver.resolveBoolean(response)) { + setting.infractions = [...Infractions]; + return { index }; + } + return { index: 'SETTING_NO_CHANGE' }; + } const infs = response.split(' ') .map((inf) => this.client.resolver.resolveInfraction(inf)) diff --git a/src/structure/components/settings/moderation/Grantable.js b/src/structure/components/settings/moderation/Grantable.js index be636cc..42cabea 100644 --- a/src/structure/components/settings/moderation/Grantable.js +++ b/src/structure/components/settings/moderation/Grantable.js @@ -52,6 +52,9 @@ class Grantable extends Setting { params: { list: 'roles' } }); if (response.error) return response; + if (roles.value === 'reset' && !this.client.resolver.resolveBoolean(response)) { + return { index: 'SETTING_NO_CHANGE' }; + } const { guild } = interaction; const params = Util.parseQuotes(response).map(([param]) => param); diff --git a/src/structure/components/settings/moderation/InviteFilter.js b/src/structure/components/settings/moderation/InviteFilter.js index 60345c4..dd9eb8c 100644 --- a/src/structure/components/settings/moderation/InviteFilter.js +++ b/src/structure/components/settings/moderation/InviteFilter.js @@ -107,6 +107,9 @@ class InviteFilterSetting extends FilterSetting { time }); if (content.error) return content; + if (method.value === 'reset' && !this.client.resolver.resolveBoolean(content)) { + return { index: 'SETTING_NO_CHANGE' }; + } const words = Util.parseQuotes(content).map(([word]) => word); let params = []; diff --git a/src/structure/components/settings/moderation/LinkFilter.js b/src/structure/components/settings/moderation/LinkFilter.js index 060906f..7a65a32 100644 --- a/src/structure/components/settings/moderation/LinkFilter.js +++ b/src/structure/components/settings/moderation/LinkFilter.js @@ -125,6 +125,9 @@ class LinkFilterSetting extends FilterSetting { time }); if (content.error) return content; + if (method.value === 'reset' && !this.client.resolver.resolveBoolean(content)) { + return { index: 'SETTING_NO_CHANGE' }; + } const words = Util.parseQuotes(content).map(([word]) => word), invalid = []; diff --git a/src/structure/components/settings/moderation/MentionFilter.js b/src/structure/components/settings/moderation/MentionFilter.js index 65cea17..f1b353e 100644 --- a/src/structure/components/settings/moderation/MentionFilter.js +++ b/src/structure/components/settings/moderation/MentionFilter.js @@ -101,6 +101,9 @@ class MentionFilter extends FilterSetting { time }); if (content.error) return content; + if (method.value === 'reset' && !this.client.resolver.resolveBoolean(content)) { + return { index: 'SETTING_NO_CHANGE' }; + } const words = Util.parseQuotes(content).map(([word]) => word); let params = []; diff --git a/src/structure/components/settings/moderation/WordFilter.js b/src/structure/components/settings/moderation/WordFilter.js index 0fcff16..3b044d8 100644 --- a/src/structure/components/settings/moderation/WordFilter.js +++ b/src/structure/components/settings/moderation/WordFilter.js @@ -116,6 +116,9 @@ class WordFilterSetting extends FilterSetting { time }); if (content.error) return content; + if (method.value === 'reset' && !this.client.resolver.resolveBoolean(content)) { + return { index: 'SETTING_NO_CHANGE' }; + } const words = Util.parseQuotes(content).map(([word]) => word), invalid = []; diff --git a/src/structure/components/settings/moderation/WordWatcher.js b/src/structure/components/settings/moderation/WordWatcher.js index 3c26034..192a39c 100644 --- a/src/structure/components/settings/moderation/WordWatcher.js +++ b/src/structure/components/settings/moderation/WordWatcher.js @@ -80,6 +80,9 @@ class WordWatcher extends FilterSetting { time }); if (content.error) return content; + if (method.value === 'reset' && !this.client.resolver.resolveBoolean(content)) { + return { index: 'SETTING_NO_CHANGE' }; + } const words = Util.parseQuotes(content).map(([word]) => word), invalid = []; diff --git a/src/structure/components/settings/utility/Autorole.js b/src/structure/components/settings/utility/Autorole.js index cdfd252..8b3d20e 100644 --- a/src/structure/components/settings/utility/Autorole.js +++ b/src/structure/components/settings/utility/Autorole.js @@ -56,6 +56,9 @@ class Autorole extends Setting { time }); if (content.error) return content; + if (method.value === 'reset' && !this.client.resolver.resolveBoolean(content)) { + return { index: 'SETTING_NO_CHANGE' }; + } const words = Util.parseQuotes(content).map(([word]) => word); const params = (await guild.resolveRoles(words)).filter((r) => !r.managed); diff --git a/src/structure/components/settings/utility/Selfrole.js b/src/structure/components/settings/utility/Selfrole.js index c0cb64d..a11e74e 100644 --- a/src/structure/components/settings/utility/Selfrole.js +++ b/src/structure/components/settings/utility/Selfrole.js @@ -48,6 +48,10 @@ class SelfroleSetting extends Setting { params: { list: 'roles' } }); if (response.error) return response; + if (roles.value === 'reset' && !this.client.resolver.resolveBoolean(response)) { + return { index: 'SETTING_NO_CHANGE' }; + } + const params = Util.parseQuotes(response).map(([param]) => param); const values = (await guild.resolveRoles(params)).filter((r) => !r.managed).map((r) => r.id); this[roles.value](setting.roles, values); diff --git a/src/structure/components/settings/utility/StickyRole.js b/src/structure/components/settings/utility/StickyRole.js index 521b43a..3b149e2 100644 --- a/src/structure/components/settings/utility/StickyRole.js +++ b/src/structure/components/settings/utility/StickyRole.js @@ -56,6 +56,9 @@ class Autorole extends Setting { time }); if (content.error) return content; + if (method.value === 'reset' && !this.client.resolver.resolveBoolean(content)) { + return { index: 'SETTING_NO_CHANGE' }; + } const words = Util.parseQuotes(content).map(([word]) => word); const params = (await guild.resolveRoles(words)).filter((r) => !r.managed);