use autoincrement
This commit is contained in:
parent
af2ebeb43f
commit
d647aad6bc
11
src/main.c
11
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)) {
|
||||
|
|
Loading…
Reference in a new issue