A Discord bot that searches for images on Danbooru.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.7 KiB

package main
import (
"git.packetlostandfound.us/chiefnoah/GoGetMeHentai/commands"
"git.packetlostandfound.us/chiefnoah/GoGetMeHentai/config"
"git.packetlostandfound.us/chiefnoah/GoGetMeHentai/database"
"github.com/bwmarrin/discordgo"
"log"
"time"
)
func main() {
//Load config
cfg := config.LoadConfig()
log.Printf("Connecting with token: %s", cfg.AppConfig.AuthToken)
discord, err := discordgo.New("Bot " + cfg.AppConfig.AuthToken)
if err != nil {
log.Fatal("Unable to authenticate with discord. RIP")
return
}
log.Printf("Connecting to discord...")
err = discord.Open()
if err != nil {
log.Fatal("Unable to open connection: ", err)
return
}
defer discord.Close()
database.Init() //Initialize the database
commands.Init() //Just load the config here
//Listen for precense update
discord.AddHandler(func(s *discordgo.Session, m *discordgo.PresenceUpdate) {
//log.Print("User: ", m.User.Username, "\nPrecense: ", m.Presence.Status)
})
discord.AddHandler(func(s *discordgo.Session, m *discordgo.MessageCreate) {
//log.Print("Author: ", m.Author.Username, "\n Content: ", m.Content)
if len(m.Content) > 0 && string(m.Content[0]) == cfg.AppConfig.CommandPrefix {
commands.ParseCommand(s, m.Message)
}
})
//fmt.Printf("%+s", gu)
//fmt.Print(gu.Channels[0].Name)
//ch, err := discord.GuildChannels(guildID)
/*message, err := discord.ChannelMessageSend(ch[0].ID, "Hello Anand. I'm told to be afraid of you :3")
if err != nil || message == nil {
log.Printf("Unable to send messagea: ", err)
}*/
//Update online status every 10 seconds. This keeps the bot alive.
for {
discord.UpdateStatus(0, "with Onii-chan")
time.Sleep(10 * time.Second)
}
}