-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstructs.go
executable file
·47 lines (41 loc) · 1.25 KB
/
structs.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
package main
import (
"encoding/json"
"io"
"io/ioutil"
"time"
"github.com/bwmarrin/discordgo"
)
//Config Holds general configuration of the bot
type Config struct {
Token string `json:"token"`
GameRoleEmbed *discordgo.MessageEmbed `json:"gameRoleEmbed"`
Guilds map[string]*GuildConfig `json:"guildID:GuildConfig"`
}
//GuildConfig Holds Guild specific configuration
type GuildConfig struct {
TalkRoleID string `json:"talkRoleID"`
TalkChannelID string `json:"talkChannelID"`
MusicBotID string `json:"musicBotID"`
BotChannelID string `json:"botChannelID"`
GameRoles []*Gamerole `json:"gameRoles"`
MemeFriendlyChannels []string `json:"memeFriendlyChannels"`
ControlMessageID string
lastUsedExpensiveCommand time.Time
}
//Gamerole holds data regarding a Gamerole
type Gamerole struct {
EmojiName string `json:"emoji"`
RoleID string `json:"roleID"`
}
func (conf *Config) populateFromReader(reader io.Reader) error {
jsonBytes, err := ioutil.ReadAll(reader)
if err != nil {
return err
}
err = json.Unmarshal(jsonBytes, conf)
if err != nil {
return err
}
return nil
}