fix db types
This commit is contained in:
parent
f1ca08f577
commit
90132ed9c0
4 changed files with 8 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
||||||
hf.database.run(
|
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) {
|
function setGuildData(id, key, value) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
hf.database.run(
|
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) {
|
function setUserData(id, key, value) {
|
||||||
|
|
|
@ -112,20 +112,18 @@ const VINBOARD_THREAD_ID = "1048462330201124935";
|
||||||
const VINBOARD_WEBHOOK_ID = "1048471543287660665";
|
const VINBOARD_WEBHOOK_ID = "1048471543287660665";
|
||||||
|
|
||||||
hf.database.run(
|
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) {
|
function getBoardEntry(id) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
hf.database.run(
|
hf.database.get(
|
||||||
"SELECT message_id,count,board_id FROM vinboard WHERE message_id = $id",
|
"SELECT message_id,count,board_id FROM vinboard WHERE message_id = $id",
|
||||||
{
|
{
|
||||||
$id: id,
|
$id: id,
|
||||||
},
|
},
|
||||||
function (err) {
|
(err, row) => {
|
||||||
logger.debug("vinboard", JSON.stringify(arguments));
|
|
||||||
if (err == null) {
|
if (err == null) {
|
||||||
logger.debug("vinboard", JSON.stringify(row));
|
|
||||||
resolve(row);
|
resolve(row);
|
||||||
} else {
|
} else {
|
||||||
reject(err);
|
reject(err);
|
||||||
|
@ -316,8 +314,6 @@ async function processReaction(_msg, user, reaction) {
|
||||||
const _boardMessage =
|
const _boardMessage =
|
||||||
board_channel.messages.get(dbEntry.board_id) ??
|
board_channel.messages.get(dbEntry.board_id) ??
|
||||||
(await board_channel.getMessage(dbEntry.board_id).catch(() => {}));
|
(await board_channel.getMessage(dbEntry.board_id).catch(() => {}));
|
||||||
logger.debug("vinboard", dbEntry.board_id);
|
|
||||||
logger.debug("vinboard", JSON.stringify(_boardMessage));
|
|
||||||
if (_boardMessage) {
|
if (_boardMessage) {
|
||||||
logger.verbose(
|
logger.verbose(
|
||||||
"vinboard",
|
"vinboard",
|
||||||
|
@ -335,7 +331,6 @@ async function processReaction(_msg, user, reaction) {
|
||||||
const boardMessage = await vinboard_webhook.execute(
|
const boardMessage = await vinboard_webhook.execute(
|
||||||
await createBoardMessage(msg, trueCount)
|
await createBoardMessage(msg, trueCount)
|
||||||
);
|
);
|
||||||
logger.debug("vinboard", JSON.stringify(boardMessage));
|
|
||||||
await setBoardEntry(msg.id, trueCount, boardMessage.id);
|
await setBoardEntry(msg.id, trueCount, boardMessage.id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,7 +27,7 @@ const reminderData = require(resolve(
|
||||||
));
|
));
|
||||||
|
|
||||||
hf.database.run(
|
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) {
|
function setLastRun(id, date) {
|
||||||
|
@ -89,10 +89,10 @@ hf.bot.once("ready", () => {
|
||||||
let [hour, minutes] = time.split(":");
|
let [hour, minutes] = time.split(":");
|
||||||
hour = parseInt(hour);
|
hour = parseInt(hour);
|
||||||
minutes = parseInt(minutes);
|
minutes = parseInt(minutes);
|
||||||
const lastRan = await getLastRun(data.user);
|
const lastRan = new Date(await getLastRun(data.user)).getTime();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
date != lastRan &&
|
date > lastRan &&
|
||||||
hour == data.hour &&
|
hour == data.hour &&
|
||||||
minutes == 0 &&
|
minutes == 0 &&
|
||||||
channel != null
|
channel != null
|
||||||
|
|
Loading…
Reference in a new issue