From d7056e3ec7216d2c362071be1560c53282f4577a Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Sun, 13 Mar 2016 10:13:41 -0400 Subject: [PATCH] Fix number of fields for counter inventory Fixes #11 --- plugins/counter.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/counter.go b/plugins/counter.go index 5c49f35..fa9c547 100644 --- a/plugins/counter.go +++ b/plugins/counter.go @@ -66,8 +66,9 @@ func (p *CounterPlugin) Message(message bot.Message) bool { subject = parts[1] } + log.Printf("Getting counter for %s", subject) // pull all of the items associated with "subject" - rows, err := p.DB.Query(`select * from counter where nick = ?`, subject) + rows, err := p.DB.Query(`select nick, item, count from counter where nick = ?`, subject) if err != nil { log.Fatal(err) } @@ -77,7 +78,10 @@ func (p *CounterPlugin) Message(message bot.Message) bool { for rows.Next() { count += 1 var it Item - rows.Scan(&it.Nick, &it.Item, &it.Count) + err := rows.Scan(&it.Nick, &it.Item, &it.Count) + if err != nil { + log.Printf("Error getting counter: %s", err) + } if count > 1 { resp = fmt.Sprintf("%s, ", resp)