Fix command count table not being properly registered
This commit is contained in:
parent
a0bb11dabb
commit
4309f358e7
2 changed files with 3 additions and 3 deletions
2
app.js
2
app.js
|
@ -99,7 +99,6 @@ esmBot ${esmBotVersion} (${process.env.GIT_REV})
|
||||||
// database handling
|
// database handling
|
||||||
const dbResult = await database.upgrade(logger);
|
const dbResult = await database.upgrade(logger);
|
||||||
if (dbResult === 1) return process.exit(1);
|
if (dbResult === 1) return process.exit(1);
|
||||||
await database.setup();
|
|
||||||
|
|
||||||
// process the threshold into bytes early
|
// process the threshold into bytes early
|
||||||
if (process.env.TEMPDIR && process.env.THRESHOLD) {
|
if (process.env.TEMPDIR && process.env.THRESHOLD) {
|
||||||
|
@ -119,6 +118,7 @@ esmBot ${esmBotVersion} (${process.env.GIT_REV})
|
||||||
}
|
}
|
||||||
logger.log("info", "Finished loading commands.");
|
logger.log("info", "Finished loading commands.");
|
||||||
|
|
||||||
|
await database.setup();
|
||||||
if (process.env.API_TYPE === "ws") await reloadImageConnections();
|
if (process.env.API_TYPE === "ws") await reloadImageConnections();
|
||||||
|
|
||||||
// create the oceanic client
|
// create the oceanic client
|
||||||
|
|
|
@ -14,7 +14,7 @@ export async function setup() {
|
||||||
const counts = connection.prepare("SELECT * FROM counts").all();
|
const counts = connection.prepare("SELECT * FROM counts").all();
|
||||||
const merged = new Map([...collections.commands, ...collections.messageCommands]);
|
const merged = new Map([...collections.commands, ...collections.messageCommands]);
|
||||||
|
|
||||||
if (!counts) {
|
if (!counts || counts.length === 0) {
|
||||||
for (const command of merged.keys()) {
|
for (const command of merged.keys()) {
|
||||||
connection.prepare("INSERT INTO counts (command, count) VALUES (?, ?)").run(command, 0);
|
connection.prepare("INSERT INTO counts (command, count) VALUES (?, ?)").run(command, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue