Hopefully improve error reporting
This commit is contained in:
parent
81526839cb
commit
bfccc0eac9
20
src/app.ts
20
src/app.ts
@ -30,29 +30,31 @@ client.on("shardError", err => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
process.on("unhandledRejection", (reason, promise) => {
|
process.on("unhandledRejection", (reason, promise) => {
|
||||||
log(new Error("Unhandled Rejection:"), reason, promise);
|
let message: string;
|
||||||
|
|
||||||
let message: string | Error;
|
|
||||||
|
|
||||||
if (reason instanceof Error) {
|
if (reason instanceof Error) {
|
||||||
message = reason;
|
message = `${reason.name}: ${reason.message}\n${reason.stack}`;
|
||||||
} else if (typeof reason == "string") {
|
|
||||||
message = reason;
|
|
||||||
} else {
|
} else {
|
||||||
message = String(reason);
|
message = String(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (message.includes("Connect Timeout Error") && message.includes("10000ms")) {
|
||||||
|
// Klasika
|
||||||
|
log(new Error("Discord timeout..."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log(new Error("Unhandled Rejection in app:"), reason, promise);
|
||||||
|
|
||||||
adminLog(client, "Unhandled Rejection", message);
|
adminLog(client, "Unhandled Rejection", message);
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on("uncaughtException", (err) => {
|
process.on("uncaughtException", (err) => {
|
||||||
log(new Error("Uncaught Exception:"), err);
|
log(new Error("Uncaught Exception in app:"), err);
|
||||||
|
|
||||||
let message: string | Error;
|
let message: string | Error;
|
||||||
if (err instanceof Error) {
|
if (err instanceof Error) {
|
||||||
message = err;
|
message = err;
|
||||||
} else if (typeof err == "string") {
|
|
||||||
message = err;
|
|
||||||
} else {
|
} else {
|
||||||
message = String(err);
|
message = String(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -113,8 +113,12 @@ export function log(...content: unknown[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function sendDM(user: User, txt: string) {
|
export async function sendDM(user: User, txt: string) {
|
||||||
await sendWithoutReply(await user.createDM(), txt)
|
try {
|
||||||
.catch(() => log(new Error(`dementovi ${user} nejde poslat DM ${txt}`)));
|
const channel = await user.createDM();
|
||||||
|
await sendWithoutReply(channel, txt);
|
||||||
|
} catch (e) {
|
||||||
|
log(new Error(`dementovi ${user} nejde poslat DM ${txt}`));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const rand = (max: number) => Math.floor(Math.random() * max);
|
export const rand = (max: number) => Math.floor(Math.random() * max);
|
||||||
@ -257,7 +261,7 @@ export async function messageReply(mes: SMessage, co: string | MessageCreateOpti
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Slouží k odeslání zprávy bez odpovědi na jinou zprávu a zajistí, anti-spam mechanismus bude fungovat.
|
* Slouží k odeslání zprávy bez odpovědi na jinou zprávu a zajistí, že anti-spam mechanismus bude fungovat.
|
||||||
* @param channel Kanál, kam se má zpráva odeslat
|
* @param channel Kanál, kam se má zpráva odeslat
|
||||||
* @param co Obsah zprávy, který se má odeslat
|
* @param co Obsah zprávy, který se má odeslat
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -72,7 +72,6 @@ export const novejJoin = (guild: Guild, channelId: string) => new Promise<boolea
|
|||||||
const conn = joinVoiceChannel({
|
const conn = joinVoiceChannel({
|
||||||
channelId: channelId,
|
channelId: channelId,
|
||||||
guildId,
|
guildId,
|
||||||
//@ts-ignore PIČOVINA ZASRATA!"!"!"!"!"!"!""""
|
|
||||||
adapterCreator: guild.voiceAdapterCreator
|
adapterCreator: guild.voiceAdapterCreator
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user