package core import ( "io/ioutil" "log" "gopkg.in/yaml.v2" "github.com/bwmarrin/discordgo" ) type Config struct { Token string `yaml:"token"` Name string `yaml:"name"` Talkback[] struct { Domain struct { Name string `yaml:"name"` Patterns []string `yaml:"patterns"` Answers []string `yaml:"answers"` } `yaml:"domain"` } `yaml:"talkback"` } type Command struct { name string desc string example string command func( s *discordgo.Session, m *discordgo.MessageCreate, message string) } func (c *Config) LoadConf() *Config { yamlFile, err := ioutil.ReadFile("config.yaml") if err != nil { log.Printf("yamlFile.Get err #%v ", err) } err = yaml.Unmarshal(yamlFile, c) if err != nil { log.Fatalf("Unmarshal: %v", err) } return c } var CommandRegister = make( map[string]Command) func SetCommand( aliases []string, desc string, example string, command func(s *discordgo.Session, m *discordgo.MessageCreate, message string)) { for _, alias := range aliases { c := Command{ name: alias, desc: desc, example: example, command: command} CommandRegister[alias] = c log.Printf("added %s to Register", alias) } } var ConfigRegister Config