CosmoQuestX / Rocket-Bot

The Bot of the New generation of explorers for the CosmoQuest server on Discord. Assembled with official APIs and documentation, originally created using the Github Students Program tools.
https://CosmoQuest.org/x/
2 stars 1 forks source link

Update main.js #12

Closed TheRealFakeAdmin closed 2 years ago

TheRealFakeAdmin commented 2 years ago

Description

Commands that throw errors on load no longer terminate the bot.

Original

try {
    // [...]
} catch (e) {
    e.fileName = file; // This was never used
    log(); // These show in a terminal console but not a debug console / gives the console space
    warn(new SyntaxError(`file ${file} was incorrectly setup`));
    log();
    process.exit(); // This terminates the bot
}})(file)
}

Proposed

try {
    // [...]
} catch (e) {
    e.fileName = file; // Adds the filename to the second [2/3] error message
    log();
    warn(e); // The error message from the broken command is sent to the console
    warn("SyntaxError:", `file ${file} was incorrectly setup so it was not loaded`);
    log(); // The process continues, skipping the failed command(s)
}