refactor(command.ts) properties no longer look as ugly

This commit is contained in:
Jacob Nguyen
2022-03-13 01:53:23 -06:00
parent 5b968ce442
commit 586d386afb
2 changed files with 20 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
import type { ApplicationCommandOptionData } from 'discord.js';
import type { CommandType } from '../sern';
import type { CommandType } from '../../sern';
/**
* An object that gets imported and acts as a command.
@@ -15,7 +15,6 @@ interface CommandOptions {
alias : string[] | [],
options?: ApplicationCommandOptionData[],
name? : string | undefined
}
export default CommandOptions;

View File

@@ -10,29 +10,29 @@ import type CommandOptions from "./command-options";
export abstract class Command {
protected _name? : string | undefined;
protected _ctx : Context = new Context( None, None );
protected _commandType : CommandType;
protected _options : ApplicationCommandOptionData[] | undefined;
protected _alias : string[] | undefined;
protected constructor (
private name? : string | undefined;
private ctx : Context = new Context( None, None );
private commandType : CommandType;
private options : ApplicationCommandOptionData[] | undefined;
private alias : string[] | undefined;
private constructor (
{ name, commandType, options, alias } : CommandOptions
) {
this._name = name;
this._commandType = commandType;
this.name = name;
this.commandType = commandType;
switch ( commandType ) {
case CommandType.TEXT : {
this._options = undefined;
this._alias = alias;
this.options = undefined;
this.alias = alias;
} break;
case CommandType.SLASH : {
if(alias.length < 0) throw Error(SernError.NO_ALIAS);
this._options = options;
this.options = options;
} break;
case CommandType.BOTH : {
this._options = options;
this._alias = alias;
} break;
this.options = options;
this.alias = alias;
} break
}
@@ -40,9 +40,9 @@ export abstract class Command {
abstract execute<T> ( args: Ok<T> ) : Awaitable<possibleOutput | void>;
abstract parse?<T> ( args: Arg ) : Utils.ArgType<T>;
public setCtx ( context: Context ) { this._ctx = context; }
public getName () { return this._name; }
public getCommandType () { return this._commandType; }
public getOptions() { return this._options; }
public getAlias() { return this._alias }
public setCtx ( context: Context ) { this.ctx = context; }
public getName () { return this.name; }
public getCommandType () { return this.commandType; }
public getOptions() { return this.options; }
public getAlias() { return this.alias }
}