use autoincrement
This commit is contained in:
parent
af2ebeb43f
commit
d647aad6bc
1 changed files with 6 additions and 5 deletions
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) {
|
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];
|
char buf[1024];
|
||||||
sprintf(buf, "INSERT INTO messages(id, message, reply)"
|
sprintf(buf, "INSERT INTO messages(message, reply)"
|
||||||
"VALUES('%" PRIu64 "', '%s', '%s')",
|
"VALUES('%s', '%s')",
|
||||||
msg->id, msg->referenced_message->content, msg->content);
|
msg->referenced_message->content, msg->content);
|
||||||
|
|
||||||
char* error;
|
char* error;
|
||||||
if(sqlite3_exec(db, buf, NULL, NULL, &error)) {
|
if(sqlite3_exec(db, buf, NULL, NULL, &error)) {
|
||||||
|
@ -30,7 +31,7 @@ int main(void) {
|
||||||
char* error;
|
char* error;
|
||||||
if(sqlite3_exec(db,
|
if(sqlite3_exec(db,
|
||||||
"CREATE TABLE IF NOT EXISTS messages("
|
"CREATE TABLE IF NOT EXISTS messages("
|
||||||
"id TEXT PRIMARY KEY,"
|
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
|
||||||
"message TEXT NOT NULL,"
|
"message TEXT NOT NULL,"
|
||||||
"reply TEXT NOT NULL"
|
"reply TEXT NOT NULL"
|
||||||
");", NULL, NULL, &error)) {
|
");", NULL, NULL, &error)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue