From 90132ed9c0387d2977ba967d0d4727a2223739c6 Mon Sep 17 00:00:00 2001 From: Cynthia Date: Sat, 3 Dec 2022 10:17:09 -0700 Subject: [PATCH] fix db types --- src/lib/guildData.js | 2 +- src/lib/userData.js | 2 +- src/modules/foxwells.js | 11 +++-------- src/modules/private_reminders.js | 6 +++--- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/lib/guildData.js b/src/lib/guildData.js index 2f295ad..aae13ec 100644 --- a/src/lib/guildData.js +++ b/src/lib/guildData.js @@ -1,5 +1,5 @@ hf.database.run( - "CREATE TABLE IF NOT EXISTS guild_data (key STRING PRIMARY KEY, value STRING NOT NULL) WITHOUT ROWID" + "CREATE TABLE IF NOT EXISTS guild_data (key TEXT PRIMARY KEY, value TEXT NOT NULL) WITHOUT ROWID" ); function setGuildData(id, key, value) { diff --git a/src/lib/userData.js b/src/lib/userData.js index ae30968..7910960 100644 --- a/src/lib/userData.js +++ b/src/lib/userData.js @@ -1,5 +1,5 @@ hf.database.run( - "CREATE TABLE IF NOT EXISTS user_data (key STRING PRIMARY KEY, value STRING NOT NULL) WITHOUT ROWID" + "CREATE TABLE IF NOT EXISTS user_data (key TEXT PRIMARY KEY, value TEXT NOT NULL) WITHOUT ROWID" ); function setUserData(id, key, value) { diff --git a/src/modules/foxwells.js b/src/modules/foxwells.js index 3bd7c90..83ca562 100644 --- a/src/modules/foxwells.js +++ b/src/modules/foxwells.js @@ -112,20 +112,18 @@ const VINBOARD_THREAD_ID = "1048462330201124935"; const VINBOARD_WEBHOOK_ID = "1048471543287660665"; hf.database.run( - "CREATE TABLE IF NOT EXISTS vinboard (message_id STRING NOT NULL PRIMARY KEY, count INTEGER NOT NULL, board_id STRING NOT NULL) WITHOUT ROWID" + "CREATE TABLE IF NOT EXISTS vinboard (message_id TEXT NOT NULL PRIMARY KEY, count INTEGER NOT NULL, board_id TEXT NOT NULL) WITHOUT ROWID" ); function getBoardEntry(id) { return new Promise((resolve, reject) => { - hf.database.run( + hf.database.get( "SELECT message_id,count,board_id FROM vinboard WHERE message_id = $id", { $id: id, }, - function (err) { - logger.debug("vinboard", JSON.stringify(arguments)); + (err, row) => { if (err == null) { - logger.debug("vinboard", JSON.stringify(row)); resolve(row); } else { reject(err); @@ -316,8 +314,6 @@ async function processReaction(_msg, user, reaction) { const _boardMessage = board_channel.messages.get(dbEntry.board_id) ?? (await board_channel.getMessage(dbEntry.board_id).catch(() => {})); - logger.debug("vinboard", dbEntry.board_id); - logger.debug("vinboard", JSON.stringify(_boardMessage)); if (_boardMessage) { logger.verbose( "vinboard", @@ -335,7 +331,6 @@ async function processReaction(_msg, user, reaction) { const boardMessage = await vinboard_webhook.execute( await createBoardMessage(msg, trueCount) ); - logger.debug("vinboard", JSON.stringify(boardMessage)); await setBoardEntry(msg.id, trueCount, boardMessage.id); } } else { diff --git a/src/modules/private_reminders.js b/src/modules/private_reminders.js index 36135d1..2fee1f1 100644 --- a/src/modules/private_reminders.js +++ b/src/modules/private_reminders.js @@ -27,7 +27,7 @@ const reminderData = require(resolve( )); hf.database.run( - "CREATE TABLE IF NOT EXISTS private_reminders (user STRING NOT NULL PRIMARY KEY, last_run STRING NOT NULL) WITHOUT ROWID" + "CREATE TABLE IF NOT EXISTS private_reminders (user TEXT NOT NULL PRIMARY KEY, last_run TEXT NOT NULL) WITHOUT ROWID" ); function setLastRun(id, date) { @@ -89,10 +89,10 @@ hf.bot.once("ready", () => { let [hour, minutes] = time.split(":"); hour = parseInt(hour); minutes = parseInt(minutes); - const lastRan = await getLastRun(data.user); + const lastRan = new Date(await getLastRun(data.user)).getTime(); if ( - date != lastRan && + date > lastRan && hour == data.hour && minutes == 0 && channel != null