mirror of https://github.com/velour/catbase.git
tappd: save ID in DB
This commit is contained in:
parent
bf54f421fe
commit
04fecf1987
|
@ -53,7 +53,7 @@ func (p *Tappd) mkDB() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = tx.Exec(`create table if not exists tappd (
|
_, err = tx.Exec(`create table if not exists tappd (
|
||||||
id integer primary key autoincrement,
|
id string primary key,
|
||||||
who string,
|
who string,
|
||||||
channel string,
|
channel string,
|
||||||
message string,
|
message string,
|
||||||
|
@ -70,15 +70,15 @@ func (p *Tappd) mkDB() error {
|
||||||
return nil
|
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()
|
db := p.b.DB()
|
||||||
tx, err := db.Beginx()
|
tx, err := db.Beginx()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = tx.Exec(`insert into tappd (who, channel, message, ts) values (?, ?, ? ,?)`,
|
_, err = tx.Exec(`insert into tappd (id, who, channel, message, ts) values (?, ?, ?, ? ,?)`,
|
||||||
who, channel, message, time.Now())
|
id, who, channel, message, time.Now())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return err
|
return err
|
||||||
|
@ -173,7 +173,7 @@ func (p *Tappd) tap(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
log.Error().Err(err).Msgf("error with interaction")
|
log.Error().Err(err).Msgf("error with interaction")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = p.log(who, channel, shortMsg)
|
err = p.log(info.ID, who, channel, shortMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msgf("error recording tap")
|
log.Error().Err(err).Msgf("error recording tap")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue