-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
38 lines (31 loc) · 877 Bytes
/
config.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
package main
import (
"time"
"github.com/bwmarrin/discordgo"
)
// Config contains the current bot configuration and structs
type Config struct {
Admin string
FilePath string
DefaultGameTypeFilter string
DiscordSession *discordgo.Session
ResponseTimeout time.Duration
ServerList *ConcurrentServerList
}
// NewBotConfig creates a new discord configuration to work as a discord bot.
func NewBotConfig(discordToken string) (*Config, error) {
discordSession, err := discordgo.New("Bot " + discordToken)
if err != nil {
return nil, err
}
return &Config{
DiscordSession: discordSession}, nil
}
// Open starts the connection to the discord servers
func (c *Config) Open() error {
return c.DiscordSession.Open()
}
// Close closes the session connection.
func (c *Config) Close() {
c.DiscordSession.Close()
}