31 lines
640 B
Go
Raw Normal View History

2018-07-10 15:46:17 +00:00
package commands
import (
"strings"
"github.com/animenotifier/arn/search"
"github.com/bwmarrin/discordgo"
)
// AnimeSearch shows the link for the anime list of a user.
func AnimeSearch(s *discordgo.Session, msg *discordgo.MessageCreate) bool {
2018-07-10 16:04:58 +00:00
if !strings.HasPrefix(msg.Content, "!a ") {
2018-07-10 15:46:17 +00:00
return false
}
term := msg.Content[len("!a "):]
animes := search.Anime(term, 3)
message := ""
for _, anime := range animes {
message += "https://notify.moe" + anime.Link() + "\n"
}
if len(animes) == 0 {
message = "Sorry, I couldn't find anything using that term."
}
s.ChannelMessageSend(msg.ChannelID, message)
return true
}