From de5c2f808c2f7ca7c2654764481181bb443c479a Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Fri, 25 Jan 2013 16:36:19 -0500 Subject: [PATCH] whoops, crashed when no first previously existed --- plugins/first.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/first.go b/plugins/first.go index 0ea7971..4cdcc12 100644 --- a/plugins/first.go +++ b/plugins/first.go @@ -32,10 +32,15 @@ func NewFirstPlugin(b *bot.Bot) *FirstPlugin { query := bson.M{"day": midnight(time.Now().UTC())} coll.Find(query).All(&firsts) + var first *FirstEntry + if len(firsts) > 0 { + first = &firsts[0] + } + return &FirstPlugin{ Bot: b, Coll: coll, - First: &firsts[0], + First: first, } }