From 37dfaef4075d9e6825ad046cab6eb639c657ba0e Mon Sep 17 00:00:00 2001 From: MARCROCK22 Date: Fri, 7 Jun 2024 16:52:05 +0000 Subject: [PATCH] fix: types and props --- src/client/onmessagecreate.ts | 1 + src/commands/applications/chat.ts | 2 ++ src/commands/applications/shared.ts | 4 ++-- src/commands/handler.ts | 15 ++++++++------- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/client/onmessagecreate.ts b/src/client/onmessagecreate.ts index 9968621..47708c8 100644 --- a/src/client/onmessagecreate.ts +++ b/src/client/onmessagecreate.ts @@ -140,6 +140,7 @@ export async function onMessageCreate( { failed: true, value: x.error, + parseError: x.fullError, }, ]; }), diff --git a/src/commands/applications/chat.ts b/src/commands/applications/chat.ts index 81c73d1..2cc6967 100644 --- a/src/commands/applications/chat.ts +++ b/src/commands/applications/chat.ts @@ -174,6 +174,7 @@ export class BaseCommand { data[i.name] = { failed: true, value: `${i.name} is required but returned no value`, + parseError: undefined, }; continue; } @@ -189,6 +190,7 @@ export class BaseCommand { data[i.name] = { failed: true, value: e instanceof Error ? e.message : typeof e === 'string' ? e : inspect(e), + parseError: undefined, }; } } diff --git a/src/commands/applications/shared.ts b/src/commands/applications/shared.ts index 96207d5..78d281d 100644 --- a/src/commands/applications/shared.ts +++ b/src/commands/applications/shared.ts @@ -64,8 +64,8 @@ export type OnOptionsReturnObject = Record< | { failed: true; value: string; - parseError?: //only for text command - MessageCommandOptionErrors; + parseError: //only for text command + MessageCommandOptionErrors | undefined; } >; diff --git a/src/commands/handler.ts b/src/commands/handler.ts index 0c6f588..8449dc5 100644 --- a/src/commands/handler.ts +++ b/src/commands/handler.ts @@ -200,18 +200,19 @@ export class CommandHandler extends BaseHandler { this.values.push(commandInstance); commandInstance.__filePath = command.path; this.__parseCommandLocales(commandInstance); + commandInstance.props ??= client.options.commands?.defaults?.props ?? {}; continue; } if (!(commandInstance instanceof Command)) { continue; } - commandInstance.onAfterRun ??= client.options?.commands?.defaults?.onAfterRun; - commandInstance.onBotPermissionsFail ??= client.options?.commands?.defaults?.onBotPermissionsFail; - commandInstance.onInternalError ??= client.options?.commands?.defaults?.onInternalError; - commandInstance.onMiddlewaresError ??= client.options?.commands?.defaults?.onMiddlewaresError; - commandInstance.onOptionsError ??= client.options?.commands?.defaults?.onOptionsError; - commandInstance.onPermissionsFail ??= client.options?.commands?.defaults?.onPermissionsFail; - commandInstance.onRunError ??= client.options?.commands?.defaults?.onRunError; + commandInstance.onAfterRun ??= client.options.commands?.defaults?.onAfterRun; + commandInstance.onBotPermissionsFail ??= client.options.commands?.defaults?.onBotPermissionsFail; + commandInstance.onInternalError ??= client.options.commands?.defaults?.onInternalError; + commandInstance.onMiddlewaresError ??= client.options.commands?.defaults?.onMiddlewaresError; + commandInstance.onOptionsError ??= client.options.commands?.defaults?.onOptionsError; + commandInstance.onPermissionsFail ??= client.options.commands?.defaults?.onPermissionsFail; + commandInstance.onRunError ??= client.options.commands?.defaults?.onRunError; commandInstance.__filePath = command.path; commandInstance.options ??= [] as NonNullable; commandInstance.props ??= client.options.commands?.defaults?.props ?? {};