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) => {
|
||||
log(new Error("Unhandled Rejection:"), reason, promise);
|
||||
|
||||
let message: string | Error;
|
||||
let message: string;
|
||||
|
||||
if (reason instanceof Error) {
|
||||
message = reason;
|
||||
} else if (typeof reason == "string") {
|
||||
message = reason;
|
||||
message = `${reason.name}: ${reason.message}\n${reason.stack}`;
|
||||
} else {
|
||||
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);
|
||||
});
|
||||
|
||||
process.on("uncaughtException", (err) => {
|
||||
log(new Error("Uncaught Exception:"), err);
|
||||
log(new Error("Uncaught Exception in app:"), err);
|
||||
|
||||
let message: string | Error;
|
||||
if (err instanceof Error) {
|
||||
message = err;
|
||||
} else if (typeof err == "string") {
|
||||
message = err;
|
||||
} else {
|
||||
message = String(err);
|
||||
}
|
||||
|
||||
@ -113,8 +113,12 @@ export function log(...content: unknown[]) {
|
||||
}
|
||||
|
||||
export async function sendDM(user: User, txt: string) {
|
||||
await sendWithoutReply(await user.createDM(), txt)
|
||||
.catch(() => log(new Error(`dementovi ${user} nejde poslat DM ${txt}`)));
|
||||
try {
|
||||
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);
|
||||
@ -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 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({
|
||||
channelId: channelId,
|
||||
guildId,
|
||||
//@ts-ignore PIČOVINA ZASRATA!"!"!"!"!"!"!""""
|
||||
adapterCreator: guild.voiceAdapterCreator
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user