more feedback when actions fail
This commit is contained in:
parent
3cac01fa60
commit
46b5d29e0f
@ -77,6 +77,7 @@ module.exports = class LinkFilter extends FilterSetting {
|
||||
const opposite = setting[_opposite];
|
||||
|
||||
let changed = [];
|
||||
const skipped = [];
|
||||
const filtered = result.resolved.filter((dom) => !opposite.includes(dom)); //Domains that don't exist in the opposing list -- safe to add
|
||||
const existsInOpposite = result.resolved.filter((dom) => opposite.includes(dom)); //Domains that exist in the opposing list
|
||||
if (result.method === 'reset') {
|
||||
@ -87,7 +88,10 @@ module.exports = class LinkFilter extends FilterSetting {
|
||||
} else if (result.method === 'add') {
|
||||
|
||||
for (const domain of filtered) {
|
||||
if (setting[method].includes(domain)) continue;
|
||||
if (setting[method].includes(domain)) {
|
||||
skipped.push(domain);
|
||||
continue;
|
||||
}
|
||||
setting[method].push(domain);
|
||||
changed.push(domain);
|
||||
}
|
||||
@ -103,14 +107,24 @@ module.exports = class LinkFilter extends FilterSetting {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
index = 'S_LINKFILTER_' + result.method.toUpperCase();
|
||||
langParams = {
|
||||
domains: changed.join('`, `') || '`N/A`',
|
||||
filter: method,
|
||||
opposite: existsInOpposite.length ? message.format('S_LINKFILTER_OPPOSITE', { opposite: existsInOpposite.join('`, `'), op: _opposite }) : ''
|
||||
filter: method
|
||||
};
|
||||
|
||||
let msg = message.format(index, langParams);
|
||||
if (existsInOpposite.length) msg += '\n\n' + message.format('S_LINKFILTER_OPPOSITE', { opposite: existsInOpposite.join('`, `'), op: _opposite });
|
||||
if (skipped.length) msg += '\n\n' + message.format('S_LINKFILTER_SKIPPED', { skipped: skipped.join('`, `') });
|
||||
if (result.failed.length) msg += '\n\n' + message.format('S_LINKFILTER_FAILED', { failed: result.failed.join('`, `') });
|
||||
|
||||
await message.guild._updateSettings({ [this.index]: setting });
|
||||
return {
|
||||
error: false,
|
||||
msg
|
||||
};
|
||||
|
||||
} else if (['ignore', 'channelignore', 'ignorechannel'].includes(method)) {
|
||||
|
||||
const resolved = await resolver.resolveMethod(args, null, setting.ignore, {
|
||||
|
@ -304,11 +304,9 @@ Configure the link filtering behaviour for your server.
|
||||
|
||||
[S_LINKFILTER_ADD]
|
||||
Successfully added `{domains}` to the **{filter}** filter.
|
||||
{opposite}
|
||||
|
||||
[S_LINKFILTER_SET]
|
||||
Successfully set the {filter} filter to **{domains}**.
|
||||
{opposite}
|
||||
|
||||
[S_LINKFILTER_REMOVE]
|
||||
Successfully removed **{domains}** from the {filter}.
|
||||
@ -326,6 +324,14 @@ Successfully set the link filtering to **{mode}** mode.
|
||||
The following links exist in the **{op}** filter and were skipped
|
||||
`{opposite}`
|
||||
|
||||
[S_LINKFILTER_SKIPPED]
|
||||
The following domains are already in the filter and were skipped.
|
||||
`{skipped}`
|
||||
|
||||
[S_LINKFILTER_FAILED]
|
||||
The following entries failed to resolve to a valid domain.
|
||||
`{failed}`
|
||||
|
||||
[S_LINKFILTER_ACTION_ADD_TRIGGERS]
|
||||
Which domains should trigger this action? If you want this action to be a generic one (i.e. it is triggered for any filter event that doesn't have a an action tied to it) respond with **gen**eric.
|
||||
Alternatively you can respond with **whitelist** or **blacklist** if you want the action to be tied to a filter list.
|
||||
|
Loading…
Reference in New Issue
Block a user