diff --git a/.rgignore b/.rgignore new file mode 100644 index 0000000..8fce603 --- /dev/null +++ b/.rgignore @@ -0,0 +1 @@ +data/ diff --git a/src/index.js b/src/index.js index c6ca6de..e09a91b 100644 --- a/src/index.js +++ b/src/index.js @@ -69,7 +69,7 @@ for (const file of fs.readdirSync(resolve(__dirname, "modules"), {withFileTypes: require(`#modules/${file.name}`); logger.info("hf:modules", `Loaded module: "${file.name}"`); } catch (err) { - logger.error("hf:modules", `Failed to load "${file.name}": ${err}`); + logger.error("hf:modules", `Failed to load "${file.name}": ${err.stack}`); } } @@ -89,9 +89,7 @@ bot.on("messageCreate", async (msg) => { await CommandDispatcher(msg); } catch (err) { - const stack = (err?.stack ?? err.message).split("\n"); - const error = stack.shift(); - logger.error("hf:main", `Failed to dispatch command: ${error}\n\t${stack.join("\n\t")}`); + logger.error("hf:main", `Failed to dispatch command: ${err.stack}`); } }); bot.on("messageUpdate", async (msg, oldMsg) => { @@ -101,9 +99,7 @@ bot.on("messageUpdate", async (msg, oldMsg) => { await CommandDispatcher(msg); } } catch (err) { - const stack = (err?.stack ?? err.message).split("\n"); - const error = stack.shift(); - logger.error("hf:main", `Failed to dispatch command update: ${error}\n\t${stack.join("\n\t")}`); + logger.error("hf:main", `Failed to dispatch command update: ${err.stack}`); } }); bot.on("messageReactionAdd", async (msg, reaction, reactor) => { @@ -133,18 +129,14 @@ bot.on("messageReactionAdd", async (msg, reaction, reactor) => { await msg.delete("Command sender requested output deletion."); } catch (err) { - const stack = (err?.stack ?? err.message).split("\n"); - const error = stack.shift(); - logger.error("hf:main", `Failed to self-delete message: ${error}\n\t${stack.join("\n\t")}`); + logger.error("hf:main", `Failed to self-delete message: ${err.stack}`); } }); bot.on("interactionCreate", async (interaction) => { try { await InteractionDispatcher(interaction); } catch (err) { - const stack = (err?.stack ?? err.message).split("\n"); - const error = stack.shift(); - logger.error("hf:main", `Failed to dispatch interaction command: ${error}\n\t${stack.join("\n\t")}`); + logger.error("hf:main", `Failed to dispatch interaction command: ${err.stack}`); } }); @@ -160,7 +152,7 @@ bot.once("ready", async () => { }); } } catch (err) { - logger.error("hf:main", `Failed to send startup message, API probably broken currently.\n${err}`); + logger.error("hf:main", `Failed to send startup message, API probably broken currently.\n${err.stack}`); } bot.on("ready", () => { logger.info("hf:main", "Reconnected to Discord."); @@ -209,23 +201,23 @@ bot.once("ready", async () => { try { await bot.requestHandler.request("PUT", APIEndpoints.COMMANDS(bot.application.id), true, commands); } catch (err) { - logger.error("hf:main", `Failed to update interaction commands, API probably broken currently.\n${err}`); + logger.error("hf:main", `Failed to update interaction commands, API probably broken currently.\n${err.stack}`); } } }); bot.on("error", (err) => { - logger.error("hf:main", "Catching error: " + err); + logger.error("hf:main", `Catching error: ${err.stack}`); }); bot.on("warn", (err) => { - logger.warn("hf:main", "Catching warn: " + err); + logger.warn("hf:main", `Catching warn: ${err}`); }); bot.on("shardDisconnect", (err, id) => { - logger.verbose("hf:shard", `Disconnecting from shard ${id}: ${err}`); + logger.verbose("hf:shard", `Disconnecting from shard ${id}: ${err.stack}`); }); bot.on("shardResume", (id) => { - logger.verbose("hf:shard", "Resuming on shard " + id); + logger.verbose("hf:shard", `Resuming on shard ${id}`); }); bot.on("shardPreReady", (id) => { logger.verbose("hf:shard", `Shard ${id} getting ready`); @@ -234,7 +226,7 @@ bot.on("shardReady", (id) => { logger.verbose("hf:shard", `Shard ${id} ready`); }); bot.on("unknown", (packet, id) => { - logger.verbose("hf:main", `Shard ${id} caught unknown packet: ${JSON.stringify(packet)}`); + logger.verbose("hf:main", `Shard ${id} caught unknown packet:\n ${JSON.stringify(packet)}`); }); instead("spawn", bot.shards, function (args, orig) {