1
0

decoupled some stuffs, news related tests, new commands file

This commit is contained in:
2020-12-08 14:47:34 +01:00
parent 804ed6ee5b
commit 53d01e04fe
6 changed files with 103 additions and 68 deletions

View File

@ -5,7 +5,6 @@ import (
"log"
"gopkg.in/yaml.v2"
"github.com/bwmarrin/discordgo"
)
type Config struct {
@ -20,16 +19,6 @@ type Config struct {
} `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 {
@ -42,23 +31,4 @@ func (c *Config) LoadConf() *Config {
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