From 28c39c889f130c3afa956aae88cf8be7c620e8f2 Mon Sep 17 00:00:00 2001 From: Danil Nikolaev Date: Wed, 2 Oct 2024 00:29:45 +0300 Subject: [PATCH] fix error on cmd execution --- src/commands/cmd.ts | 16 +++++++++++----- src/common/constants.ts | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/commands/cmd.ts b/src/commands/cmd.ts index 8d46274..ccadb9a 100644 --- a/src/commands/cmd.ts +++ b/src/commands/cmd.ts @@ -1,6 +1,6 @@ -import {Command, Requirement, Requirements} from "../model/chat-command"; -import {Utils} from "../util/utils"; -import {Api} from "../api/api"; +import { Command, Requirement, Requirements } from "../model/chat-command"; +import { Utils } from "../util/utils"; +import { Api } from "../api/api"; import { MessageContext, ContextDefaultState } from "vk-io"; export class Cmd extends Command { @@ -14,7 +14,13 @@ export class Cmd extends Command { async execute(context: MessageContext, params: any[]) { const text = params[1]; - const result = await Utils.executeCommand(text); - await Api.sendMessage(context, result); + Utils + .executeCommand(text) + .then(async (r) => await Api.sendMessage(context, r)) + .catch(async (e) => { + console.error(e); + await Api.sendMessage(context, "Произошла ошибка"); + } + ); } } \ No newline at end of file diff --git a/src/common/constants.ts b/src/common/constants.ts index ef3ccb5..41c7061 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -1 +1 @@ -export const BOT_VERSION = "0.0.5"; \ No newline at end of file +export const BOT_VERSION = "0.0.6"; \ No newline at end of file