2024-03-28 16:53:53 +01:00
|
|
|
/* eslint-disable max-classes-per-file */
|
2024-04-10 16:23:15 +02:00
|
|
|
import { CommandOption, AbstractResolver } from '@navy.gif/commandparser';
|
2024-03-28 16:53:53 +01:00
|
|
|
|
2024-04-10 16:23:15 +02:00
|
|
|
class Resolver implements AbstractResolver
|
2024-03-28 16:53:53 +01:00
|
|
|
{
|
|
|
|
resolveMember<Member, Guild> (_resolveable: string, _strict: boolean, _guild: Guild): Promise<Member | null>
|
|
|
|
{
|
|
|
|
throw new Error('Method not implemented.');
|
|
|
|
}
|
|
|
|
resolveRole<Role, Guild> (_resolveable: string, _strict: boolean, _guild: Guild): Promise<Role | null>
|
|
|
|
{
|
|
|
|
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<User> (_rawValue: string[], _strict: boolean)
|
|
|
|
{
|
|
|
|
const users: User[] = [];
|
|
|
|
return users;
|
|
|
|
}
|
|
|
|
async resolveUser<User> (arg0: string, strict: boolean)
|
|
|
|
{
|
|
|
|
const users = await this.resolveUsers<User>([ arg0 ], strict);
|
|
|
|
return users[0] ?? null;
|
|
|
|
}
|
|
|
|
resolveChannel<Channel> (_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;
|