mirror of
https://github.com/artiemis/artemis.js.git
synced 2026-02-14 10:21:54 +00:00
notify about other errors
This commit is contained in:
parent
3845df0ba3
commit
6846371810
@ -13,7 +13,7 @@ import {
|
|||||||
isTargetLanguage,
|
isTargetLanguage,
|
||||||
translate as translateDeepl,
|
translate as translateDeepl,
|
||||||
} from "../../utils/deepl";
|
} from "../../utils/deepl";
|
||||||
import { abort } from "../../utils/error";
|
import { abort, notifyError } from "../../utils/error";
|
||||||
import type { OCRResult } from "../../types/ocr";
|
import type { OCRResult } from "../../types/ocr";
|
||||||
import { capitalize, languageCodeToName } from "../../utils/functions";
|
import { capitalize, languageCodeToName } from "../../utils/functions";
|
||||||
import { translate as translateGoogle } from "../../utils/gtrans";
|
import { translate as translateGoogle } from "../../utils/gtrans";
|
||||||
@ -52,6 +52,7 @@ export async function translateImpl(
|
|||||||
target
|
target
|
||||||
).catch(err => {
|
).catch(err => {
|
||||||
logger.error(err, "DeepL error, falling back to Google Translate");
|
logger.error(err, "DeepL error, falling back to Google Translate");
|
||||||
|
notifyError(err);
|
||||||
return translateGoogle(text, "auto", "en");
|
return translateGoogle(text, "auto", "en");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import {
|
|||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import { defineCommand } from "..";
|
import { defineCommand } from "..";
|
||||||
import { downloadFile } from "../../utils/http";
|
import { downloadFile } from "../../utils/http";
|
||||||
import { abort } from "../../utils/error";
|
import { abort, notifyError } from "../../utils/error";
|
||||||
import { yandexOcr } from "../../utils/yandex";
|
import { yandexOcr } from "../../utils/yandex";
|
||||||
import sharp from "sharp";
|
import sharp from "sharp";
|
||||||
import {
|
import {
|
||||||
@ -88,6 +88,7 @@ export async function ocrImpl(url: string) {
|
|||||||
const result = await lensOcr(compressed)
|
const result = await lensOcr(compressed)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
logger.error(err, "Google Lens error, falling back to Yandex");
|
logger.error(err, "Google Lens error, falling back to Yandex");
|
||||||
|
notifyError(err);
|
||||||
return yandexOcr(compressed, type.mime);
|
return yandexOcr(compressed, type.mime);
|
||||||
})
|
})
|
||||||
.catch(() => abort("Failed to OCR the image"));
|
.catch(() => abort("Failed to OCR the image"));
|
||||||
|
|||||||
@ -75,7 +75,7 @@ async function handleChatInputCommand(
|
|||||||
const trace = nanoid();
|
const trace = nanoid();
|
||||||
content += `\ntrace: ${inlineCode(trace)}`;
|
content += `\ntrace: ${inlineCode(trace)}`;
|
||||||
logger.error({ trace, err });
|
logger.error({ trace, err });
|
||||||
notifyError(trace, err);
|
notifyError(err, trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
await interaction[
|
await interaction[
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export function isExplicitCommandError(
|
|||||||
return error instanceof ExplicitCommandError;
|
return error instanceof ExplicitCommandError;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function notifyError(trace: string, error: any) {
|
export async function notifyError(error: any, trace?: string) {
|
||||||
return (client.channels.cache.get(env.DEV_CHANNEL_ID) as TextChannel).send({
|
return (client.channels.cache.get(env.DEV_CHANNEL_ID) as TextChannel).send({
|
||||||
content: trace,
|
content: trace,
|
||||||
embeds: [
|
embeds: [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user