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)) {