From 04fecf1987c34799fcc3c021f14ae9176ceb7a49 Mon Sep 17 00:00:00 2001 From: Chris Sexton <3216719+chrissexton@users.noreply.github.com> Date: Sat, 15 Oct 2022 10:19:34 -0400 Subject: [PATCH] tappd: save ID in DB --- plugins/tappd/tappd.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/tappd/tappd.go b/plugins/tappd/tappd.go index 1de3b4a..7c8d404 100644 --- a/plugins/tappd/tappd.go +++ b/plugins/tappd/tappd.go @@ -53,7 +53,7 @@ func (p *Tappd) mkDB() error { return err } _, err = tx.Exec(`create table if not exists tappd ( - id integer primary key autoincrement, + id string primary key, who string, channel string, message string, @@ -70,15 +70,15 @@ func (p *Tappd) mkDB() error { return nil } -func (p *Tappd) log(who, channel, message string) error { +func (p *Tappd) log(id, who, channel, message string) error { db := p.b.DB() tx, err := db.Beginx() if err != nil { tx.Rollback() return err } - _, err = tx.Exec(`insert into tappd (who, channel, message, ts) values (?, ?, ? ,?)`, - who, channel, message, time.Now()) + _, err = tx.Exec(`insert into tappd (id, who, channel, message, ts) values (?, ?, ?, ? ,?)`, + id, who, channel, message, time.Now()) if err != nil { tx.Rollback() return err @@ -173,7 +173,7 @@ func (p *Tappd) tap(s *discordgo.Session, i *discordgo.InteractionCreate) { log.Error().Err(err).Msgf("error with interaction") return } - err = p.log(who, channel, shortMsg) + err = p.log(info.ID, who, channel, shortMsg) if err != nil { log.Error().Err(err).Msgf("error recording tap") }