Fixed discord bot source

This commit is contained in:
Eduard Urbach 2018-03-18 05:49:30 +01:00
parent 19f6a2b572
commit 9772729ea7

View File

@ -3,7 +3,6 @@ package main
import ( import (
"strings" "strings"
"github.com/animenotifier/arn"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
) )
@ -60,40 +59,40 @@ func OnMessageCreate(s *discordgo.Session, msg *discordgo.MessageCreate) {
return return
} }
if strings.HasPrefix(msg.Content, "!s ") { // if strings.HasPrefix(msg.Content, "!s ") {
term := msg.Content[len("!s "):] // term := msg.Content[len("!s "):]
users, animes, posts, threads, tracks, characters := arn.Search(term, 3, 3, 3, 3, 3, 3) // users, animes, posts, threads, tracks, characters := arn.Search(term, 3, 3, 3, 3, 3, 3)
message := "" // message := ""
for _, user := range users { // for _, user := range users {
message += "https://notify.moe" + user.Link() + "\n" // message += "https://notify.moe" + user.Link() + "\n"
} // }
for _, anime := range animes { // for _, anime := range animes {
message += "https://notify.moe" + anime.Link() + "\n" // message += "https://notify.moe" + anime.Link() + "\n"
} // }
for _, post := range posts { // for _, post := range posts {
message += "https://notify.moe" + post.Link() + "\n" // message += "https://notify.moe" + post.Link() + "\n"
} // }
for _, thread := range threads { // for _, thread := range threads {
message += "https://notify.moe" + thread.Link() + "\n" // message += "https://notify.moe" + thread.Link() + "\n"
} // }
for _, track := range tracks { // for _, track := range tracks {
message += "https://notify.moe" + track.Link() + "\n" // message += "https://notify.moe" + track.Link() + "\n"
} // }
for _, character := range characters { // for _, character := range characters {
message += "https://notify.moe" + character.Link() + "\n" // message += "https://notify.moe" + character.Link() + "\n"
} // }
if len(users) == 0 && len(animes) == 0 && len(posts) == 0 && len(threads) == 0 && len(tracks) == 0 { // if len(users) == 0 && len(animes) == 0 && len(posts) == 0 && len(threads) == 0 && len(tracks) == 0 {
message = "Sorry, I couldn't find anything using that term." // message = "Sorry, I couldn't find anything using that term."
} // }
s.ChannelMessageSend(msg.ChannelID, message) // s.ChannelMessageSend(msg.ChannelID, message)
return // return
} // }
} }