-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
37 lines (30 loc) · 802 Bytes
/
config.go
File metadata and controls
37 lines (30 loc) · 802 Bytes
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
package main
import (
"encoding/json"
"io"
)
// GuildConfig is the config per guild
type GuildConfig struct {
Year string `json:"year"`
Mode string `json:"mode"`
LeaderboardID string `json:"leaderboard_id"`
DailyRoles bool `json:"daily_roles"`
}
// Config is the bot config
type Config struct {
// The Discord bot token
DiscordToken string `json:"discord_token"`
// The Advent of Code session cookie
SessionCookie string `json:"session_cookie"`
// Map guild ids to (year, leaderboard id) pairs
Guilds map[string]GuildConfig `json:"guilds"`
}
// ParseConfig parses a config file
func ParseConfig(reader io.Reader) (*Config, error) {
var config Config
err := json.NewDecoder(reader).Decode(&config)
if err != nil {
return nil, err
}
return &config, nil
}