-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
66 lines (57 loc) · 2.01 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
59
60
61
62
63
64
65
66
package main
import (
"flag"
"fmt"
"log"
"math/rand"
"os"
"os/signal"
"syscall"
"time"
"github.com/discord-gophers/dgobot/commands"
"github.com/bwmarrin/discordgo"
"github.com/bwmarrin/lit"
"github.com/peterbourgon/ff/v3"
)
func main() {
fmt.Printf(`
.___ ___. __
__| _/ ____ ____\_ |__ _____/ |_
/ __ | / ___\ / _ \| __ \ / _ \ __\
/ /_/ |/ /_/ > <_> ) \_\ ( <_> ) |
\____ |\___ / \____/|___ /\____/|__|
\/_____/ \/ %s`+"\n\n", commands.Version)
fs := flag.NewFlagSet("dgobot", flag.ExitOnError)
token := fs.String("token", "", "Discord Authentication Token")
domain := fs.String("domain", "https://f.teamortix.com", "Filehost domain")
pass := fs.String("pass", "", "Filehost upload password (empty if none)")
fs.StringVar(&commands.AdminUserID, "admin-id", "109112383011581952", "Discord Admin ID")
fs.StringVar(&commands.HerderRoleID, "herder-id", "370280974593818644", "Discord Herder Role ID")
fs.IntVar(&lit.LogLevel, "log-level", 0, "LogLevel (0-3)")
if err := ff.Parse(fs, os.Args[1:], ff.WithEnvVarPrefix("DG")); err != nil {
lit.Error("could not parse flags: %v", err)
return
}
// Seed rand for any random commands
rand.Seed(time.Now().UnixNano())
session, err := discordgo.New("Bot " + *token)
if err != nil {
fmt.Fprintf(fs.Output(), "Usage of %s:\n", fs.Name())
fs.PrintDefaults()
log.Println("You must provide a Discord authentication token.")
return
}
session.Identify.Intents = discordgo.IntentsAllWithoutPrivileged | discordgo.IntentsGuildMembers
session.AddHandler(commands.OnInteractionCommand)
session.AddHandler(commands.OnAutocomplete)
session.AddHandler(commands.OnModalSubmit)
commands.InitURLib(*domain, *pass)
if err := session.Open(); err != nil {
log.Fatalf("error opening connection to Discord: %v", err)
}
defer session.Close()
log.Println(`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
}