-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (31 loc) · 1.05 KB
/
main.go
File metadata and controls
36 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"log"
"os"
"os/signal"
"github.com/bwmarrin/discordgo"
"github.com/common-nighthawk/go-figure"
"github.com/tpc3/Bocchi-Re/lib"
"github.com/tpc3/Bocchi-Re/lib/config"
"github.com/tpc3/Bocchi-Re/lib/database"
)
func main() {
database.InitDB(config.CurrentConfig.Data + "tokens.sqlite3")
discord, err := discordgo.New("Bot " + config.CurrentConfig.Discord.Token)
if err != nil {
log.Fatal("Error creating Discord session: ", err)
}
discord.AddHandler(func(s *discordgo.Session, m *discordgo.MessageCreate) { go lib.MessageCreate(s, m) })
discord.Identify.Intents = discordgo.MakeIntent(discordgo.IntentsGuilds | discordgo.IntentsGuildMessages | discordgo.IntentsMessageContent)
err = discord.Open()
if err != nil {
log.Fatal("Error opening connection: ", err)
}
discord.UpdateGameStatus(0, config.CurrentConfig.Discord.Status)
figure.NewColorFigure("Bocchi-Re", "", "green", true).Print()
log.Print("Bocchi-Re is now running!")
defer discord.Close()
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt)
<-stop
}