feat(command.ts) throw error on alias present on slash command

This commit is contained in:
Jacob Nguyen
2022-03-12 00:56:24 -06:00
parent ecf7ecc92c
commit 840619d7c5
3 changed files with 14 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import Context from "../context";
import type * as Utils from '../../utilities/preprocessors/args';
import { None, Ok } from "ts-results";
import { CommandType } from "../../sern";
import { SernError } from "../errors";
export abstract class Command {
@@ -15,22 +16,27 @@ export abstract class Command {
protected _alias : string[] | undefined;
protected constructor (
commandType : CommandType,
alias : string[] | [],
options?: ApplicationCommandOptionData[],
alias? : string[],
name? : string | undefined
) {
this._name = name;
this._commandType = commandType;
switch ( commandType ) {
case CommandType.TEXT : {
this._options = undefined;
this._alias = alias;
this._options = undefined;
} break;
case CommandType.SLASH : case CommandType.BOTH : {
this._alias = undefined
case CommandType.SLASH : {
if(alias.length < 0) throw Error(SernError.NO_ALIAS);
this._options = options;
} break;
case CommandType.BOTH : {
this._options = options;
this._alias = alias;
} break;
}
}

View File

@@ -1,4 +1,4 @@
export enum SernError {
RESERVED_EVENT = 'Cannot register the reserved ready event. Please use the init property.'
RESERVED_EVENT = 'Cannot register the reserved ready event. Please use the init property.',
NO_ALIAS = 'You cannot provide an array with elements to a slash command.'
}