30 lines
615 B
Go
Raw Normal View History

2018-07-10 15:46:17 +00:00
package commands
import (
"math/rand"
"github.com/akyoto/color"
2019-06-03 09:32:43 +00:00
"github.com/animenotifier/notify.moe/arn"
2018-07-10 15:46:17 +00:00
"github.com/bwmarrin/discordgo"
)
// RandomQuote shows a random quote.
func RandomQuote(s *discordgo.Session, msg *discordgo.MessageCreate) bool {
if msg.Content != "!randomquote" {
return false
}
allQuotes := arn.FilterQuotes(func(quote *arn.Quote) bool {
return !quote.IsDraft && quote.IsValid()
})
quote := allQuotes[rand.Intn(len(allQuotes))]
_, err := s.ChannelMessageSend(msg.ChannelID, "https://notify.moe"+quote.Link())
if err != nil {
color.Red(err.Error())
}
2018-07-10 15:46:17 +00:00
return true
}