changed resolveMethod to use opts param

This commit is contained in:
Erik 2020-09-27 21:16:09 +03:00
parent 690fca08c2
commit 48237b8edb
6 changed files with 17 additions and 11 deletions

View File

@ -43,7 +43,7 @@ class IgnoreSetting extends Setting {
const setting = message.guild._settings[this.index];
const { guild } = message;
const { resolver } = this.client;
const response = await resolver.resolveMethod(params, null, setting.channels, resolver.resolveChannels.bind(resolver), guild);
const response = await resolver.resolveMethod(params, null, setting.channels, { resolver: resolver.resolveChannels.bind(resolver), guild });
if (!response) method = params.shift();
else ({ method } = response);
@ -93,7 +93,7 @@ class IgnoreSetting extends Setting {
} else if (method === 'bypass') {
const response = await resolver.resolveMethod(params, null, setting.roleBypass, resolver.resolveRoles.bind(resolver), guild);
const response = await resolver.resolveMethod(params, null, setting.roleBypass, { resolver: resolver.resolveRoles.bind(resolver), guild });
if (response.method === 'add') {

View File

@ -55,7 +55,7 @@ class MessageLogsSetting extends Setting {
msg: message.format('MISSING_ARGS'),
error: true
};
const response = await this.resolveMethod(args, undefined, setting.ignoredRoles, guild.resolveRoles.bind(guild));
const response = await this.resolveMethod(args, undefined, setting.ignoredRoles, { resolver: guild.resolveRoles.bind(guild) });
if (response) {
@ -102,7 +102,7 @@ class MessageLogsSetting extends Setting {
msg: message.format('MISSING_ARGS'),
error: true
};
const response = await this.resolveMethod(args, null, setting.ignoredChannels, guild.resolveChannels.bind(guild));
const response = await this.resolveMethod(args, null, setting.ignoredChannels, { resolver: guild.resolveChannels.bind(guild) });
if (response) {

View File

@ -52,7 +52,7 @@ class ProtectionSetting extends Setting {
} else {
const response = await resolver.resolveMethod(params, null, setting.roles, resolver.resolveRoles.bind(resolver), guild);
const response = await resolver.resolveMethod(params, null, setting.roles, { resolver: resolver.resolveRoles.bind(resolver), guild });
if (!response) return { error: true, msg: message.format('ERR_INVALID_METHOD', { method }) };
({ method } = response);
if (method !== 'list' && !response.resolved.length) return { error: true, msg: message.format('ERR_ROLERESOLVE') };

View File

@ -33,7 +33,10 @@ class AutoroleSetting extends Setting {
const setting = message.guild._settings[this.index];
const { guild } = message;
const { resolver } = this.client;
const response = await resolver.resolveMethod(params, null, setting.roles, resolver.resolveRoles.bind(resolver), guild);
const response = await resolver.resolveMethod(params, null, setting.roles, {
resolver: resolver.resolveRoles.bind(resolver),
guild
});
let index = null,
langParams = {};

View File

@ -37,7 +37,10 @@ class StickyRoleSetting extends Setting {
const langParams = {};
let index = null;
const response = await resolver.resolveMethod(params, null, setting.roles, resolver.resolveRoles.bind(resolver), guild);
const response = await resolver.resolveMethod(params, null, setting.roles, {
resolver: resolver.resolveRoles.bind(resolver),
guild
});
if (!response) return {
error: true,
msg: message.format('ERR_INVALID_METHOD', { method: params[0] })

View File

@ -64,8 +64,8 @@ class Setting extends Component {
* @returns {Object}
* @memberof Resolver
*/
resolveMethod(args, valid, existing, resolver, guild, caseSensitive) {
return this.client.resolver.resolveMethod(args, valid, existing, resolver, guild, caseSensitive);
resolveMethod(args, valid, existing, opts) {
return this.client.resolver.resolveMethod(args, valid, existing, opts);
}
reason(executor) {
@ -125,9 +125,9 @@ class Setting extends Component {
return {
author: {
name: `${this.name}${this.module ? ` (${this.module.resolveable})` : ''}`
name: `${this.display}${this.module ? ` (${this.module.resolveable})` : ''}`
},
description: stripIndents`\`${prefix}setting ${this.name}${this.usage ? ` ${this.usage}` : ''}\`${this.guildOnly ? ' *(guild-only)*' : ''}
description: stripIndents`\`${prefix}setting ${this.display}${this.usage ? ` ${this.usage}` : ''}\`${this.guildOnly ? ' *(guild-only)*' : ''}
${message.format(this.description)}`,
fields
};