Logy chyby, DM chyby a mnohem lepší start.sh
This commit is contained in:
parent
ff3d928a41
commit
88022bd15f
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ res/customKomandy.json
|
|||||||
res/customAliasy.json
|
res/customAliasy.json
|
||||||
zaznamy.dlog
|
zaznamy.dlog
|
||||||
zvuky/priVstupu
|
zvuky/priVstupu
|
||||||
|
logs
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.54.3",
|
"version": "3001.54.4",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.54.3",
|
"version": "3001.54.4",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/voice": "^0.16.0",
|
"@discordjs/voice": "^0.16.0",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.54.3",
|
"version": "3001.54.4",
|
||||||
"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/"
|
||||||
|
|||||||
@ -39,7 +39,7 @@ const runEvent = (name: string, args: unknown[]) => {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (process.env.dieOnError) throw e;
|
if (process.env.dieOnError) throw e;
|
||||||
log("error pri spusteni super listeneru", e as Error);
|
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) {
|
} catch (e) {
|
||||||
if (process.env.dieOnError) throw e;
|
if (process.env.dieOnError) throw e;
|
||||||
log("error pri spousteni eventu", e as Error);
|
log("error pri spousteni eventu", e as Error);
|
||||||
adminLog(client, "error pri eventu");
|
adminLog(client, "error pri eventu", e as Error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -35,7 +35,7 @@ async function playNext(guildId: string, seek?: number) {
|
|||||||
|
|
||||||
log(e);
|
log(e);
|
||||||
const client: Client = module.exports.client;
|
const client: Client = module.exports.client;
|
||||||
adminLog(client, "error v hani muziky");
|
adminLog(client, "error v hani muziky", e as Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import { Modul } from "../utils/types";
|
|||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import { adminLog, formatCas, log, nabidni, sendDM } from "../utils/utils";
|
import { adminLog, formatCas, log, nabidni, sendDM } from "../utils/utils";
|
||||||
import { emouty } from "../utils/emotes";
|
import { emouty } from "../utils/emotes";
|
||||||
|
import { readFileSync } from "fs";
|
||||||
|
|
||||||
const zpravy = new Map<string, Map<string, number[]>>();
|
const zpravy = new Map<string, Map<string, number[]>>();
|
||||||
const dobaOmezení = 20_000;
|
const dobaOmezení = 20_000;
|
||||||
@ -82,8 +83,7 @@ const exp: Modul = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
lastuptime: () => {
|
lastuptime: () => {
|
||||||
const index = process.argv.length > 3 ? 3 : 2;
|
const sekundy = Number(process.argv[3]);
|
||||||
const sekundy = Number(process.argv[index]);
|
|
||||||
if (!sekundy) return "aj forgor 💀";
|
if (!sekundy) return "aj forgor 💀";
|
||||||
return `naposled jsem jel ${formatCas(sekundy)}`;
|
return `naposled jsem jel ${formatCas(sekundy)}`;
|
||||||
}
|
}
|
||||||
@ -131,9 +131,12 @@ const exp: Modul = {
|
|||||||
// Nastavení clienta
|
// Nastavení clienta
|
||||||
client = module.exports.client;
|
client = module.exports.client;
|
||||||
|
|
||||||
// OG onReady
|
// OG onReady++
|
||||||
log("A jedeš!");
|
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
|
// Server na navrhy
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
|
|||||||
@ -68,15 +68,15 @@ export const formatter = new Intl.DateTimeFormat("cs", { day: "numeric", month:
|
|||||||
|
|
||||||
export const ping = /^<@!?\d+>$/;
|
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) {
|
if (process.env.adminChannel) {
|
||||||
const adminChannel = client.channels.cache.get(process.env.adminChannel);
|
const adminChannel = client.channels.cache.get(process.env.adminChannel);
|
||||||
if (adminChannel?.type == ChannelType.GuildText)
|
if (adminChannel?.type == ChannelType.GuildText)
|
||||||
adminChannel.send(text);
|
adminChannel.send(!!err ? `${text}\n\`\`\`${err}\`\`\`` : text);
|
||||||
}
|
}
|
||||||
if (process.env.adminID) {
|
if (process.env.adminID) {
|
||||||
const user = client.users.cache.get(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
30
start.sh
30
start.sh
@ -1,26 +1,38 @@
|
|||||||
declare -a casy
|
declare -a casy
|
||||||
i=0
|
i=0
|
||||||
|
posel=0
|
||||||
while true; do
|
while true; do
|
||||||
cas=$(date +"%s")
|
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
|
echo stahuju update
|
||||||
git stash
|
git stash
|
||||||
git pull
|
git pull
|
||||||
npm i --omit=dev
|
npm i --omit=dev
|
||||||
live-tsc -s src -d out -f cjs
|
live-tsc -s src -d out -f cjs
|
||||||
unset posel
|
|
||||||
else
|
else
|
||||||
kod=$?
|
|
||||||
echo [$(date +"%d.%m. %H:%M:%S")]: poslo to
|
|
||||||
echo exit code byl $kod
|
|
||||||
if (($kod == 69)); then
|
if (($kod == 69)); then
|
||||||
echo jenom restart
|
echo jenom restart
|
||||||
else
|
else
|
||||||
posel=1
|
posel=1
|
||||||
casy[$i]=$(date +"%s")
|
casy[$i]=$casDva
|
||||||
posledni=$(($((casy[$i])) - $cas))
|
if (($i < 3)) || (($((casy[$(($i - 3))])) < $(($casDva - 86400)))); then
|
||||||
|
|
||||||
if (($i < 3)) || (($((casy[$(($i - 3))])) < $(($((casy[$i])) - 864000)))); then
|
|
||||||
echo Poslo to dostatecne malo, restartuju
|
echo Poslo to dostatecne malo, restartuju
|
||||||
else
|
else
|
||||||
echo Poslo to moc, seru na to
|
echo Poslo to moc, seru na to
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user