-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
52 lines (43 loc) · 881 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"github.com/pelletier/go-toml"
"os"
)
type DiscordConfig struct {
Token string
Status string
Prefix string
PurgeTime int
PlayStatus bool
GuildID string
ChannelID string
}
type YouTubeConfig struct {
Token string
}
type VKConfig struct {
Token string
}
type PathsConfig struct {
YoutubeDL string `toml:"youtube-dl"`
FFmpeg string `toml:"ffmpeg"`
}
type Config struct {
Discord DiscordConfig
YouTube YouTubeConfig
VK VKConfig
Paths PathsConfig
}
func LoadConfig(file string) (*Config, error) {
f, err := os.Open(file)
if err != nil {
return nil, err
}
defer f.Close()
config := &Config{}
decoder := toml.NewDecoder(f)
if err := decoder.Decode(config); err != nil {
return nil, err
}
return config, nil
}