43 lines
979 B
Go
43 lines
979 B
Go
package main
|
|
|
|
import (
|
|
"ariona.fr/git/gator/gogodiscordo/core"
|
|
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
)
|
|
|
|
func main() {
|
|
core.Config.LoadConf()
|
|
discord, err := discordgo.New("Bot " + core.Config.Token)
|
|
if err != nil {
|
|
fmt.Println("error creating Discord session, ", err)
|
|
return
|
|
}
|
|
|
|
core.SetCommand([]string{"/ggd audio", "/gogodisco audio"}, core.MessageAudio)
|
|
core.SetCommand([]string{"ping", "pong"}, core.MessagePing)
|
|
core.SetCommand([]string{"/ggd help", "/gogodisco help"}, core.MessageHelp)
|
|
|
|
discord.AddHandler(core.MessageHandler)
|
|
|
|
err = discord.Open()
|
|
if err != nil {
|
|
fmt.Println("error opening connection, ", err)
|
|
return
|
|
}
|
|
|
|
// Wait here until CTRL-C or other term signal is received.
|
|
fmt.Println("Bot is now running. Press CTRL-C to exit.")
|
|
sc := make(chan os.Signal, 1)
|
|
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
|
|
<-sc
|
|
|
|
// Cleanly close down the Discord session.
|
|
discord.Close()
|
|
}
|