fix: types and props

This commit is contained in:
MARCROCK22 2024-06-07 16:52:05 +00:00
parent f061dccf3f
commit 37dfaef407
4 changed files with 13 additions and 9 deletions

View File

@ -140,6 +140,7 @@ export async function onMessageCreate(
{
failed: true,
value: x.error,
parseError: x.fullError,
},
];
}),

View File

@ -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,
};
}
}

View File

@ -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;
}
>;

View File

@ -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<Command['options']>;
commandInstance.props ??= client.options.commands?.defaults?.props ?? {};