clean up reset prompt

This commit is contained in:
Erik 2022-08-19 15:52:57 +03:00
parent 7043e8f259
commit fa1258b9ea
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
15 changed files with 64 additions and 6 deletions

View File

@ -26,6 +26,9 @@ Respond with what you want to **remove** from the **{list}** list.
[SETTING_PROMPT_SET] [SETTING_PROMPT_SET]
Respond with what you want to **set** the **{list}** list to. 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 // General filter stuff
[SETTING_FILTER_ACTION_ADD] [SETTING_FILTER_ACTION_ADD]
Successfully added a **{type}** action for {trigger} filter events. Successfully added a **{type}** action for {trigger} filter events.

View File

@ -55,6 +55,9 @@ class IgnoreSetting extends Setting {
params: { list: list.value } params: { list: list.value }
}); });
if (response.error) return response; 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); const params = Util.parseQuotes(response).map(([param]) => param);
let values = []; let values = [];

View File

@ -69,6 +69,9 @@ class ProtectionSetting extends Setting {
params: { list: 'roles' } params: { list: 'roles' }
}); });
if (response.error) return response; if (response.error) return response;
if (roles.value === 'reset' && !this.client.resolver.resolveBoolean(response)) {
return { index: 'SETTING_NO_CHANGE' };
}
const { guild } = interaction; const { guild } = interaction;
const params = Util.parseQuotes(response).map(([param]) => param); const params = Util.parseQuotes(response).map(([param]) => param);

View File

@ -107,14 +107,23 @@ class DmInfraction extends Setting {
if (anonymous) setting.anonymous = anonymous.value; if (anonymous) setting.anonymous = anonymous.value;
if (infractions) { 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, { const response = await this._prompt(interaction, {
message: `${interaction.format(`SETTING_PROMPT_${infractions.value.toUpperCase()}`, { message: `${interaction.format(`SETTING_PROMPT_${infractions.value.toUpperCase()}`, {
list: 'infractions' list: 'infractions'
})}\n\n${interaction.format('SETTING_DMINFRACTION_VALID', { })}${reset ? '' : extra}`
valid: Infractions.join(`, `)
})}`
}); });
if (response.error) return response; 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(' ') const infs = response.split(' ')
.map((inf) => this.client.resolver.resolveInfraction(inf)) .map((inf) => this.client.resolver.resolveInfraction(inf))

View File

@ -114,6 +114,9 @@ class MessageLog extends Setting {
time time
}); });
if (content.error) return content; 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 words = Util.parseQuotes(content).map(([word]) => word);

View File

@ -85,14 +85,23 @@ class ModerationLog extends Setting {
if (enabled) setting.enabled = enabled.value; if (enabled) setting.enabled = enabled.value;
if (infractions) { 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, { const response = await this._prompt(interaction, {
message: `${interaction.format(`SETTING_PROMPT_${infractions.value.toUpperCase()}`, { message: `${interaction.format(`SETTING_PROMPT_${infractions.value.toUpperCase()}`, {
list: 'infractions' list: 'infractions'
})}\n\n${interaction.format('SETTING_DMINFRACTION_VALID', { })}${reset ? '' : extra}`
valid: Infractions.join(`, `)
})}`
}); });
if (response.error) return response; 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(' ') const infs = response.split(' ')
.map((inf) => this.client.resolver.resolveInfraction(inf)) .map((inf) => this.client.resolver.resolveInfraction(inf))

View File

@ -52,6 +52,9 @@ class Grantable extends Setting {
params: { list: 'roles' } params: { list: 'roles' }
}); });
if (response.error) return response; if (response.error) return response;
if (roles.value === 'reset' && !this.client.resolver.resolveBoolean(response)) {
return { index: 'SETTING_NO_CHANGE' };
}
const { guild } = interaction; const { guild } = interaction;
const params = Util.parseQuotes(response).map(([param]) => param); const params = Util.parseQuotes(response).map(([param]) => param);

View File

@ -107,6 +107,9 @@ class InviteFilterSetting extends FilterSetting {
time time
}); });
if (content.error) return content; 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 words = Util.parseQuotes(content).map(([word]) => word);
let params = []; let params = [];

View File

@ -125,6 +125,9 @@ class LinkFilterSetting extends FilterSetting {
time time
}); });
if (content.error) return content; 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 words = Util.parseQuotes(content).map(([word]) => word),
invalid = []; invalid = [];

View File

@ -101,6 +101,9 @@ class MentionFilter extends FilterSetting {
time time
}); });
if (content.error) return content; 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 words = Util.parseQuotes(content).map(([word]) => word);
let params = []; let params = [];

View File

@ -116,6 +116,9 @@ class WordFilterSetting extends FilterSetting {
time time
}); });
if (content.error) return content; 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 words = Util.parseQuotes(content).map(([word]) => word),
invalid = []; invalid = [];

View File

@ -80,6 +80,9 @@ class WordWatcher extends FilterSetting {
time time
}); });
if (content.error) return content; 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 words = Util.parseQuotes(content).map(([word]) => word),
invalid = []; invalid = [];

View File

@ -56,6 +56,9 @@ class Autorole extends Setting {
time time
}); });
if (content.error) return content; 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 words = Util.parseQuotes(content).map(([word]) => word);
const params = (await guild.resolveRoles(words)).filter((r) => !r.managed); const params = (await guild.resolveRoles(words)).filter((r) => !r.managed);

View File

@ -48,6 +48,10 @@ class SelfroleSetting extends Setting {
params: { list: 'roles' } params: { list: 'roles' }
}); });
if (response.error) return response; 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 params = Util.parseQuotes(response).map(([param]) => param);
const values = (await guild.resolveRoles(params)).filter((r) => !r.managed).map((r) => r.id); const values = (await guild.resolveRoles(params)).filter((r) => !r.managed).map((r) => r.id);
this[roles.value](setting.roles, values); this[roles.value](setting.roles, values);

View File

@ -56,6 +56,9 @@ class Autorole extends Setting {
time time
}); });
if (content.error) return content; 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 words = Util.parseQuotes(content).map(([word]) => word);
const params = (await guild.resolveRoles(words)).filter((r) => !r.managed); const params = (await guild.resolveRoles(words)).filter((r) => !r.managed);