Don't crash on PluginNotLoadedError

This commit is contained in:
Dragory 2021-08-20 22:13:02 +03:00
parent 4878589786
commit d0139f6c2e
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -20,6 +20,7 @@ import { startUptimeCounter } from "./uptime";
import { errorMessage, isDiscordAPIError, isDiscordHTTPError, SECONDS, successMessage } from "./utils";
import { loadYamlSafely } from "./utils/loadYamlSafely";
import { DecayingCounter } from "./utils/DecayingCounter";
import { PluginNotLoadedError } from "knub/dist/plugins/PluginNotLoadedError";
if (!process.env.KEY) {
// tslint:disable-next-line:no-console
@ -106,6 +107,13 @@ function errorHandler(err) {
return;
}
if (err instanceof PluginNotLoadedError) {
// We don't want to crash the bot here, although this *should not happen*
// TODO: Proper system for preventing plugin load/unload race conditions
console.error(err);
return;
}
// tslint:disable:no-console
console.error(err);