/* eslint-disable max-classes-per-file */ import { CommandOption, AbstractResolver } from '@navy.gif/commandparser'; class Resolver implements AbstractResolver { resolveMember (_resolveable: string, _strict: boolean, _guild: Guild): Promise { throw new Error('Method not implemented.'); } resolveRole (_resolveable: string, _strict: boolean, _guild: Guild): Promise { throw new Error('Method not implemented.'); } resolveBoolean (_resolveable: string): boolean | null { throw new Error('Method not implemented.'); } resolveTime (_resolveable: string): number | null { throw new Error('Method not implemented.'); } resolveUsers (_rawValue: string[], _strict: boolean) { const users: User[] = []; return users; } async resolveUser (arg0: string, strict: boolean) { const users = await this.resolveUsers([ arg0 ], strict); return users[0] ?? null; } resolveChannel (_arg0: string) { return {} as Channel; } } // These functions are called by the command option class // All you need to do is implement them as you need class ExtendedCommandOption extends CommandOption { declare options: ExtendedCommandOption[]; declare protected resolver: Resolver; protected async USERS () { if (!this.resolver) throw new Error('Missing resolver'); if (!this.rawValue) throw new Error('Missing raw value'); const member = await this.resolver.resolveUsers(this.rawValue, this.strict); if (!member) return { error: true }; return { value: member, removed: this.rawValue }; } protected async USER () { if (!this.resolver) throw new Error('Missing resolver'); if (!this.rawValue) throw new Error('Missing raw value'); const member = await this.resolver.resolveUser(this.rawValue[0], this.strict); if (!member) return { error: true }; return { value: member, removed: [ this.rawValue[0] ] }; } protected async TEXT_CHANNEL () { if (!this.resolver) throw new Error('Missing resolver'); if (!this.rawValue) throw new Error('Missing raw value'); const channel = await this.resolver.resolveChannel < {isTextBased:() => boolean}>(this.rawValue[0]); if (!channel || !channel.isTextBased()) return { error: true }; return { value: channel, removed: [ this.rawValue[0] ] }; } } export default ExtendedCommandOption;