Logy chyby, DM chyby a mnohem lepší start.sh

This commit is contained in:
Histmy 2023-10-21 23:40:23 +02:00
parent ff3d928a41
commit 88022bd15f
8 changed files with 38 additions and 22 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ res/customKomandy.json
res/customAliasy.json
zaznamy.dlog
zvuky/priVstupu
logs

4
package-lock.json generated
View File

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

View File

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

View File

@ -39,7 +39,7 @@ const runEvent = (name: string, args: unknown[]) => {
} catch (e) {
if (process.env.dieOnError) throw e;
log("error pri spusteni super listeneru", e as Error);
adminLog(client, "error pri supereventu");
adminLog(client, "error pri supereventu", e as Error);
}
}
@ -49,7 +49,7 @@ const runEvent = (name: string, args: unknown[]) => {
} catch (e) {
if (process.env.dieOnError) throw e;
log("error pri spousteni eventu", e as Error);
adminLog(client, "error pri eventu");
adminLog(client, "error pri eventu", e as Error);
}
});
};

View File

@ -35,7 +35,7 @@ async function playNext(guildId: string, seek?: number) {
log(e);
const client: Client = module.exports.client;
adminLog(client, "error v hani muziky");
adminLog(client, "error v hani muziky", e as Error);
}
}

View File

@ -7,6 +7,7 @@ import { Modul } from "../utils/types";
import fetch from "node-fetch";
import { adminLog, formatCas, log, nabidni, sendDM } from "../utils/utils";
import { emouty } from "../utils/emotes";
import { readFileSync } from "fs";
const zpravy = new Map<string, Map<string, number[]>>();
const dobaOmezení = 20_000;
@ -82,8 +83,7 @@ const exp: Modul = {
},
lastuptime: () => {
const index = process.argv.length > 3 ? 3 : 2;
const sekundy = Number(process.argv[index]);
const sekundy = Number(process.argv[3]);
if (!sekundy) return "aj forgor 💀";
return `naposled jsem jel ${formatCas(sekundy)}`;
}
@ -131,9 +131,12 @@ const exp: Modul = {
// Nastavení clienta
client = module.exports.client;
// OG onReady
// OG onReady++
log("A jedeš!");
if (process.argv.length >= 4) adminLog(client, "pošel jsem");
if (process.argv[2] == "1") {
const duvod = readFileSync("logs/recent2.txt").toString();
adminLog(client, "pošel jsem", duvod);
}
// Server na navrhy
createServer((req, res) => {

View File

@ -68,15 +68,15 @@ export const formatter = new Intl.DateTimeFormat("cs", { day: "numeric", month:
export const ping = /^<@!?\d+>$/;
export function adminLog(client: Client, text: string) {
export function adminLog(client: Client, text: string, err?: string | Error) {
if (process.env.adminChannel) {
const adminChannel = client.channels.cache.get(process.env.adminChannel);
if (adminChannel?.type == ChannelType.GuildText)
adminChannel.send(text);
adminChannel.send(!!err ? `${text}\n\`\`\`${err}\`\`\`` : text);
}
if (process.env.adminID) {
const user = client.users.cache.get(process.env.adminID);
if (user) sendDM(user, text);
if (user) sendDM(user, !!err ? `${text}\n\`\`\`${err}\`\`\`` : text);
}
}

View File

@ -1,26 +1,38 @@
declare -a casy
i=0
posel=0
while true; do
cas=$(date +"%s")
if node . $posel $posledni; then
node . $posel $posledni 2> >(tee logs/aktualni.txt)
kod=$?
posel=0
echo [$(date +"%d.%m. %H:%M:%S")]: vyplo sa to
casDva=$(date +"%s")
posledni=$(($casDva - $cas))
cp logs/aktualni.txt logs/recent.txt
if [[ -s "logs/aktualni.txt" ]]; then
cp logs/aktualni.txt logs/$(date +"%d.%m.-%H-%M-%S-%N").txt
fi
echo exit code byl $kod
if (($kod == 0 )); then
echo stahuju update
git stash
git pull
npm i --omit=dev
live-tsc -s src -d out -f cjs
unset posel
else
kod=$?
echo [$(date +"%d.%m. %H:%M:%S")]: poslo to
echo exit code byl $kod
if (($kod == 69)); then
echo jenom restart
else
posel=1
casy[$i]=$(date +"%s")
posledni=$(($((casy[$i])) - $cas))
if (($i < 3)) || (($((casy[$(($i - 3))])) < $(($((casy[$i])) - 864000)))); then
casy[$i]=$casDva
if (($i < 3)) || (($((casy[$(($i - 3))])) < $(($casDva - 86400)))); then
echo Poslo to dostatecne malo, restartuju
else
echo Poslo to moc, seru na to