From 7250cace67b1a9118ef1b287e134d87d31c8cff0 Mon Sep 17 00:00:00 2001 From: GRZ4NA Date: Mon, 2 Aug 2021 22:18:24 +0200 Subject: [PATCH] system messages types WIP --- src/Command.ts | 2 +- src/SystemMessage.ts | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Command.ts b/src/Command.ts index cf7f7ca..98e5cf0 100644 --- a/src/Command.ts +++ b/src/Command.ts @@ -268,7 +268,7 @@ export class CommandManager { ) { argumentsList.splice(0, 1); } - if (command.arguments) { + if (command.arguments.length > 0) { command.arguments.map((a, i) => { if (!argumentsList[i] && !a.optional) { throw new MissingArgumentError(a); diff --git a/src/SystemMessage.ts b/src/SystemMessage.ts index 503e331..46956d3 100644 --- a/src/SystemMessage.ts +++ b/src/SystemMessage.ts @@ -11,7 +11,11 @@ import { import { Command } from "./Command.js"; import { PermissionsError } from "./Error.js"; -export type MessageType = "PERMISSION" | "ERROR" | "NOT_FOUND"; +export type MessageType = + | "PERMISSION" + | "ERROR" + | "NOT_FOUND" + | "MISSING_ARGUMENT"; export interface SystemMessageAppearance { enabled: boolean; title: string; @@ -31,6 +35,8 @@ export class SystemMessageManager { PERMISSION: SystemMessageAppearance; ERROR: SystemMessageAppearance; NOT_FOUND: SystemMessageAppearance; + MISSING_ARGUMENT: SystemMessageAppearance; + ARGUMENT_TYPE_MISMATCH: SystemMessageAppearance; deleteTimeout: number; constructor(botName?: string) { @@ -57,6 +63,23 @@ export class SystemMessageManager { showTimestamp: true, footer: botName, }; + this.MISSING_ARGUMENT = { + enabled: true, + title: "🛑 Missing arguments", + bottomText: + "This command requires an argument that you didn't provide", + accentColor: "#ff0000", + showTimestamp: true, + footer: botName, + }; + this.ARGUMENT_TYPE_MISMATCH = { + enabled: true, + title: "📝 Wrong argument type", + bottomText: "This command requires a different type of argument", + accentColor: "#ff0000", + showTimestamp: true, + footer: botName, + }; this.deleteTimeout = Infinity; } @@ -153,6 +176,7 @@ export class SystemMessageManager { } } break; + //TODO Add argument error processing } } if (channel) {