whoops, crashed when no first previously existed

This commit is contained in:
Chris Sexton 2013-01-25 16:36:19 -05:00
parent 6434b27626
commit de5c2f808c
1 changed files with 6 additions and 1 deletions

View File

@ -32,10 +32,15 @@ func NewFirstPlugin(b *bot.Bot) *FirstPlugin {
query := bson.M{"day": midnight(time.Now().UTC())} query := bson.M{"day": midnight(time.Now().UTC())}
coll.Find(query).All(&firsts) coll.Find(query).All(&firsts)
var first *FirstEntry
if len(firsts) > 0 {
first = &firsts[0]
}
return &FirstPlugin{ return &FirstPlugin{
Bot: b, Bot: b,
Coll: coll, Coll: coll,
First: &firsts[0], First: first,
} }
} }