error handling for action building

This commit is contained in:
Erik 2021-06-13 17:52:41 +03:00
parent d4ceb44be9
commit ed4a498fc8
No known key found for this signature in database
GPG Key ID: 7E862371D3409F16
4 changed files with 22 additions and 0 deletions

View File

@ -120,6 +120,11 @@ module.exports = class InviteFilter extends FilterSetting {
} }
if (langParams.error) return {
error: true,
msg: langParams.msg
};
await message.guild._updateSettings({ [this.index]: setting }); await message.guild._updateSettings({ [this.index]: setting });
return { return {
error: false, error: false,

View File

@ -202,6 +202,11 @@ module.exports = class LinkFilter extends FilterSetting {
msg: message.format('ERR_INVALID_METHOD', { method }) msg: message.format('ERR_INVALID_METHOD', { method })
}; };
if (langParams.error) return {
error: true,
msg: langParams.msg
};
await message.guild._updateSettings({ [this.index]: setting }); await message.guild._updateSettings({ [this.index]: setting });
return { return {
error: false, error: false,

View File

@ -149,6 +149,11 @@ module.exports = class MentionFilter extends FilterSetting {
msg: message.format('ERR_INVALID_METHOD', { method }) msg: message.format('ERR_INVALID_METHOD', { method })
}; };
if (langParams.error) return {
error: true,
msg: langParams.msg
};
await message.guild._updateSettings({ [this.index]: setting }); await message.guild._updateSettings({ [this.index]: setting });
return { return {
error: false, error: false,

View File

@ -53,6 +53,7 @@ module.exports = class WordFilter extends FilterSetting {
async handle(message, params) { async handle(message, params) {
// eslint-disable-next-line prefer-const
let [method, ...args] = params; let [method, ...args] = params;
method = method.toLowerCase(); method = method.toLowerCase();
@ -254,6 +255,11 @@ module.exports = class WordFilter extends FilterSetting {
}; };
} }
if (langParams.error) return {
error: true,
msg: langParams.msg
};
await message.guild._updateSettings({ [this.index]: setting }); await message.guild._updateSettings({ [this.index]: setting });
return { return {
error: false, error: false,
@ -263,6 +269,7 @@ module.exports = class WordFilter extends FilterSetting {
} }
async _createTrigger(message, action, actionObject, setting) { async _createTrigger(message, action, actionObject, setting) {
const response = await message.prompt(message.format('S_WORDFILTER_ACTION_ADD_TRIGGERS'), { time: 60 * 1000 }); const response = await message.prompt(message.format('S_WORDFILTER_ACTION_ADD_TRIGGERS'), { time: 60 * 1000 });
if (!response) { if (!response) {
if (setting.actions.find((ac) => ac.trigger === 'generic')) return { if (setting.actions.find((ac) => ac.trigger === 'generic')) return {