From d647aad6bcf7b7a24aefe3ef0e38b9784d061cf8 Mon Sep 17 00:00:00 2001 From: raxracks Date: Thu, 29 Feb 2024 13:18:52 +0000 Subject: [PATCH] use autoincrement --- src/main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index be98831..41d3e35 100644 --- a/src/main.c +++ b/src/main.c @@ -11,11 +11,12 @@ void on_ready(struct discord *client, const struct discord_ready *msg) { } void on_message(struct discord *client, const struct discord_message *msg) { - if(msg->type == DISCORD_MESSAGE_REPLY) { + log_info("%s", msg->content); + if(msg->type == DISCORD_MESSAGE_REPLY && msg->content != NULL) { char buf[1024]; - sprintf(buf, "INSERT INTO messages(id, message, reply)" - "VALUES('%" PRIu64 "', '%s', '%s')", - msg->id, msg->referenced_message->content, msg->content); + sprintf(buf, "INSERT INTO messages(message, reply)" + "VALUES('%s', '%s')", + msg->referenced_message->content, msg->content); char* error; if(sqlite3_exec(db, buf, NULL, NULL, &error)) { @@ -30,7 +31,7 @@ int main(void) { char* error; if(sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS messages(" - "id TEXT PRIMARY KEY," + "id INTEGER PRIMARY KEY AUTOINCREMENT," "message TEXT NOT NULL," "reply TEXT NOT NULL" ");", NULL, NULL, &error)) {