Fix db race condition
- Fixed a bug where the bot would crash if the db connection took too long - Updated packages to latest version - Bumped version to 1.1.1
This commit is contained in:
@ -1,13 +1,21 @@
|
||||
import { runCleanup } from "../service";
|
||||
import client from "./index";
|
||||
import { initPromise } from "../data/dataSource";
|
||||
|
||||
const token = process.env["TOKEN"];
|
||||
if (!token) throw new ReferenceError("TOKEN environment variable is missing");
|
||||
|
||||
client.login(token);
|
||||
async function run() {
|
||||
console.log("Establishing database connection");
|
||||
await initPromise;
|
||||
console.log("Connection established\nAuthenticating with Discord API");
|
||||
client.login(token);
|
||||
}
|
||||
|
||||
client.on("ready", () => {
|
||||
client.on("ready", async () => {
|
||||
console.log(`Connected to Discord API. Bot account is ${client.user?.tag} (${client.user?.id})`);
|
||||
|
||||
runCleanup();
|
||||
});
|
||||
});
|
||||
|
||||
run();
|
Reference in New Issue
Block a user