-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
58 lines (48 loc) · 1.21 KB
/
main.go
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"github.com/bwmarrin/discordgo"
"github.com/jasonlvhit/gocron"
)
func main() {
fmt.Print("Loading search structure...")
updateCache()
fmt.Println(" Done")
bot, err := discordgo.New("Bot TOKEN")
if err != nil {
panic("Could not create bot: " + err.Error())
}
bot.Identify.Intents = discordgo.IntentsAllWithoutPrivileged | discordgo.IntentMessageContent
bot.AddHandler(Help)
bot.AddHandler(Search)
bot.AddHandler(DeDupe)
bot.AddHandler(DeleteDeDupe)
if bot.Open() != nil {
panic("Could not open bot: " + err.Error())
}
go func() {
gocron.Every(1).Day().Do(func() {
bot.UpdateStatusComplex(discordgo.UpdateStatusData{
Status: "idle",
AFK: true,
Activities: []*discordgo.Activity{
{
Name: "Updating search...",
Type: discordgo.ActivityTypeGame,
},
},
})
updateCache()
bot.UpdateGameStatus(0, "mention me for commands.")
})
gocron.Every(30).Minutes().Do(func() { bot.UpdateGameStatus(0, "mention me for commands.") })
}()
fmt.Println("FlutterDoc running. CTRL+C to exit")
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-sc
bot.Close()
}