Enhance error logging and update message handling in vordinace and vyhledavac modules

This commit is contained in:
Histmy 2025-12-15 14:39:33 +01:00
parent 3c206c7f4b
commit 8ee056680b
5 changed files with 15 additions and 10 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "denim_3001", "name": "denim_3001",
"version": "3001.62.8", "version": "3001.62.9",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "denim_3001", "name": "denim_3001",
"version": "3001.62.8", "version": "3001.62.9",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@discordjs/voice": "^0.19.0", "@discordjs/voice": "^0.19.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "denim_3001", "name": "denim_3001",
"version": "3001.62.8", "version": "3001.62.9",
"description": "Toto je velmi kvalitní bot.", "description": "Toto je velmi kvalitní bot.",
"repository": { "repository": {
"url": "https://github.com/Histmy/Denim-Bot/" "url": "https://github.com/Histmy/Denim-Bot/"

View File

@ -52,9 +52,9 @@ process.on("unhandledRejection", (reason, promise) => {
process.on("uncaughtException", (err) => { process.on("uncaughtException", (err) => {
log(new Error("Uncaught Exception in app:"), err); log(new Error("Uncaught Exception in app:"), err);
let message: string | Error; let message: string;
if (err instanceof Error) { if (err instanceof Error) {
message = err; message = `${err.name}: ${err.message}\n${err.stack}`;
} else { } else {
message = String(err); message = String(err);
} }

View File

@ -6,7 +6,7 @@ import { emouty } from "../utils/emotes";
let client: CClient; let client: CClient;
const logg = (...cokoli: any[]) => log("[OnePlayTest]: ", ...cokoli); const logg = (...cokoli: any[]) => log("[OnePlayDownloader]: ", ...cokoli);
const token = process.env.OnePlayToken; const token = process.env.OnePlayToken;
@ -50,14 +50,18 @@ async function udelejOneplayRquest(cesta: string, body: string) {
throw new Error("token more"); throw new Error("token more");
} }
let ok = false;
const res = await betterFetch(`https://http.cms.jyxo.cz/api/v3/${cesta}`, { const res = await betterFetch(`https://http.cms.jyxo.cz/api/v3/${cesta}`, {
method: "POST", method: "POST",
body, body,
headers: { Authorization: token } headers: { Authorization: token }
}).then(res => res.json()) }).then(res => {
ok = res.ok;
res.json();
})
.catch(e => { throw new Error(`chyba pri udelejoneplayrequest fetch ${e}`); }); .catch(e => { throw new Error(`chyba pri udelejoneplayrequest fetch ${e}`); });
logg("nejspis uspesna odpoved", res); logg(`nejspis ${ok ? "" : "ne"}uspesna odpoved`, res);
} }
const sleep = (time: number) => new Promise(res => setTimeout(res, time)); const sleep = (time: number) => new Promise(res => setTimeout(res, time));
@ -188,7 +192,7 @@ async function urobit() {
if (!guilda) return log(new Error("dobytcarna nenalezena")); if (!guilda) return log(new Error("dobytcarna nenalezena"));
const kdyToBude = new Date(); const kdyToBude = new Date();
kdyToBude.setHours(21); kdyToBude.setHours(20);
kdyToBude.setSeconds(0); kdyToBude.setSeconds(0);
let nazev = ""; let nazev = "";

View File

@ -2,7 +2,7 @@
import { APIEmbed, CommandInteractionOption, Message, TextBasedChannel } from "discord.js"; import { APIEmbed, CommandInteractionOption, Message, TextBasedChannel } from "discord.js";
import { CClient, Modul } from "../utils/types"; import { CClient, Modul } from "../utils/types";
import { bazenek, log, sendWithoutReply, strankovani } from "../utils/utils"; import { bazenek, log, messageLinks, sendWithoutReply, strankovani } from "../utils/utils";
const zpracovatZpravu = (mes: Message) => new Promise<void>(async (res, rej) => { const zpracovatZpravu = (mes: Message) => new Promise<void>(async (res, rej) => {
if ([6, 7, 8, 9, 10, 11, 18, 23, 46].includes(mes.type)) return res(); if ([6, 7, 8, 9, 10, 11, 18, 23, 46].includes(mes.type)) return res();
@ -83,6 +83,7 @@ const exp: Modul = {
} }
const odpoved = await int.reply("hledam"); const odpoved = await int.reply("hledam");
messageLinks.set(odpoved.id, "<nic>"); // Hack, ale já na tohle už nechci šahat
const sql = `SELECT CONVERT(ID, CHAR) as idcko, SUBSTRING(Content, 1, 20) AS kontent FROM Zpravy WHERE ${parsedFiltry.join(" AND ")} ORDER BY ID ${seradit}`; const sql = `SELECT CONVERT(ID, CHAR) as idcko, SUBSTRING(Content, 1, 20) AS kontent FROM Zpravy WHERE ${parsedFiltry.join(" AND ")} ORDER BY ID ${seradit}`;
bazenek.query({ sql, values: mista }, (err, res?: { idcko: string; kontent: string; }[]) => { bazenek.query({ sql, values: mista }, (err, res?: { idcko: string; kontent: string; }[]) => {