diff --git a/src/classes/CommandOption.ts b/src/classes/CommandOption.ts index 3184fad..b8a34ae 100644 --- a/src/classes/CommandOption.ts +++ b/src/classes/CommandOption.ts @@ -26,7 +26,7 @@ class CommandOption implements ICommandOption { value?: unknown; aliased = false; strict: boolean; - private resolver?: IResolver | undefined; + protected resolver?: IResolver | undefined; constructor (def: CommandOptionDefinition|CommandOption|ICommandOption) { @@ -90,7 +90,9 @@ class CommandOption implements ICommandOption { } clone (rawValue?: string[], resolver?: IResolver): CommandOption { - const opt = new CommandOption(this); + // Call own constructor, important to do it like this in order to preserve any potentially extended classes + // eslint-disable-next-line new-parens, no-extra-parens + const opt = new (this.constructor(this) as new () => typeof this); opt.rawValue = rawValue; opt.resolver = resolver; return opt; @@ -98,7 +100,7 @@ class CommandOption implements ICommandOption { async parse (guild?: unknown): Promise { if (!this[OptionType[this.type]]) - throw new Error(`Missing parsing function for ${this.type}`); + throw new Error(`Missing parsing function for ${OptionType[this.type]}`); if (typeof this[OptionType[this.type]] !== 'function') throw new Error(`Expected function type for member ${OptionType[this.type]}`); this.guild = guild;