From ab2ddea5060eb4204fd73f31b434d9a3a7adce28 Mon Sep 17 00:00:00 2001 From: bignutty <3515180-bignutty@users.noreply.gitlab.com> Date: Sun, 1 Jun 2025 18:24:36 +0200 Subject: [PATCH] fix ocrtr error, handle dictionary error --- commands/message/utils/dictionary.js | 2 ++ commands/message/utils/ocrtr.js | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/commands/message/utils/dictionary.js b/commands/message/utils/dictionary.js index 81adbcb..9331da8 100644 --- a/commands/message/utils/dictionary.js +++ b/commands/message/utils/dictionary.js @@ -88,6 +88,8 @@ module.exports = { run: async (context, args) => { await acknowledge(context); + if(!args.query || args.query.length === 0) return editOrReply(context, createEmbed("warning", context, "Missing query argument.")) + let language = dictionaryGetCodeFromAny(args.lang); if (!language) return editOrReply(context, createEmbed("warning", context, "Invalid Language")) diff --git a/commands/message/utils/ocrtr.js b/commands/message/utils/ocrtr.js index 6304e48..c52c72d 100644 --- a/commands/message/utils/ocrtr.js +++ b/commands/message/utils/ocrtr.js @@ -4,7 +4,7 @@ const { TRANSLATE_LANGUAGES, TRANSLATE_DISPLAY_MAPPINGS, PERMISSION_GROUPS } = r const { getRecentImage } = require("#utils/attachment"); const { createEmbed } = require("#utils/embed"); const { acknowledge } = require("#utils/interactions"); -const { codeblock, icon, pill, limitedString, smallIconPill } = require("#utils/markdown"); +const { codeblock, icon, pill, smallIconPill, stringwrap} = require("#utils/markdown"); const { editOrReply } = require("#utils/message"); const { STATICS } = require("#utils/statics"); const { isSupported, getCodeFromAny } = require('#utils/translate'); @@ -31,8 +31,8 @@ module.exports = { if(!args.to) args.to = "en" if(args.to.startsWith("-to")) args.to = args.to.replace("-to ", "") - if(!isSupported(args.to)) return editOrReply(context, createEmbed("warning", context, `Invalid source language (${limitedString(args.from, 10)}).`)) - if(!isSupported(args.from)) return editOrReply(context, createEmbed("warning", context, `Invalid source language (${limitedString(args.from, 10)}).`)) + if(!isSupported(args.to)) return editOrReply(context, createEmbed("warning", context, `Invalid target language (${stringwrap(args.to, 10)}).`)) + if(!isSupported(args.from)) return editOrReply(context, createEmbed("warning", context, `Invalid source language (${stringwrap(args.from, 10)}).`)) let targetLanguage = getCodeFromAny(args.to) let sourceLanguage = getCodeFromAny(args.from)