mirror of https://github.com/velour/catbase.git
whoops, crashed when no first previously existed
This commit is contained in:
parent
6434b27626
commit
de5c2f808c
|
@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue