2020-04-08 18:08:46 +02:00
|
|
|
const Component = require('./Component.js');
|
2020-04-08 16:27:34 +02:00
|
|
|
|
2020-04-08 18:08:46 +02:00
|
|
|
class Setting extends Component {
|
2020-04-08 16:27:34 +02:00
|
|
|
|
2020-04-08 18:08:46 +02:00
|
|
|
constructor(client, opts = {}) {
|
|
|
|
|
|
|
|
if(!opts) return null;
|
|
|
|
|
|
|
|
super(client, {
|
|
|
|
id: opts.name,
|
|
|
|
type: 'setting',
|
|
|
|
guarded: opts.guarded,
|
|
|
|
disabled: opts.disabled
|
|
|
|
});
|
|
|
|
|
|
|
|
this.name = opts.name;
|
|
|
|
this.module = opts.module;
|
|
|
|
this.restricted = Boolean(opts.restricted);
|
|
|
|
|
2020-05-05 15:33:14 +02:00
|
|
|
this.description = `S_${opts.name}_DESCRIPTION`;
|
|
|
|
this.examples = `S_${opts.name}_EXAMPLES`;
|
2020-04-08 18:08:46 +02:00
|
|
|
this.archiveable = Boolean(opts.archiveable);
|
|
|
|
|
|
|
|
this.index = opts.index || opts.name;
|
|
|
|
this.aliases = opts.aliases || [];
|
|
|
|
this.resolve = (opts.resolve && Constants.Resolves.includes(opts.resolve)) ? opts.resolve : 'GUILD';
|
|
|
|
this.default = opts.default;
|
2020-05-06 01:40:46 +02:00
|
|
|
this.arguments = opts.arguments || [];
|
|
|
|
this.custom = Boolean(opts.custom);
|
|
|
|
this.display = opts.display || opts.name;
|
2020-04-08 18:08:46 +02:00
|
|
|
|
|
|
|
this.memberPermissions = opts.memberPermissions || [];
|
|
|
|
this.clientPermissions = opts.clientPermissions || [];
|
|
|
|
|
2020-05-06 01:40:46 +02:00
|
|
|
this._commandHandler = null;
|
|
|
|
|
2020-04-08 18:08:46 +02:00
|
|
|
}
|
|
|
|
|
2020-05-06 01:40:46 +02:00
|
|
|
async handle() {
|
|
|
|
this.client.logger.error(`No handle function found in ${this.moduleResolveable}.`);
|
|
|
|
}
|
|
|
|
|
|
|
|
async _parseArguments(params) {
|
|
|
|
|
|
|
|
const { parsedArguments, newArgs } = await this.commandHandler._parseArguments(this.arguments, params);
|
|
|
|
return { parsedArguments, params: newArgs };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
async _handleReset(message, params) {
|
|
|
|
const response = await message.prompt(message.format('UHHH'), { error: 'warning' });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
get commandHandler() {
|
|
|
|
if(this._commandHandler) return this._commandHandler;
|
|
|
|
else return this._commandHandler = this.client.registry.components.get('observer:commandHandler');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
get moduleResolveable() {
|
|
|
|
return `${this.module.id}:${this.id}`;
|
|
|
|
}
|
2020-04-08 18:08:46 +02:00
|
|
|
|
2020-04-08 16:27:34 +02:00
|
|
|
}
|
|
|
|
|
2020-04-08 18:08:46 +02:00
|
|
|
module.exports = Setting;
|
|
|
|
|
|
|
|
const Constants = {
|
|
|
|
Resolves: [
|
|
|
|
'GUILD',
|
|
|
|
'USER'
|
|
|
|
]
|
|
|
|
};
|