const Component = require('./Component.js'); class Setting extends Component { 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); this.description = `S_${opts.name}_DESCRIPTION`; this.examples = `S_${opts.name}_EXAMPLES`; 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; this.arguments = opts.arguments || []; this.custom = Boolean(opts.custom); this.display = opts.display || opts.name; this.memberPermissions = opts.memberPermissions || []; this.clientPermissions = opts.clientPermissions || []; this._commandHandler = null; } 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 }; } 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}`; } } module.exports = Setting; const Constants = { Resolves: [ 'GUILD', 'USER' ] };