dynamically generated help message
This commit is contained in:
@ -8,12 +8,22 @@ import (
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
type ConfigRegister struct {
|
||||
type Config struct {
|
||||
Token string `yaml:"token"`
|
||||
Name string `yaml:"name"`
|
||||
}
|
||||
|
||||
func (c *ConfigRegister) LoadConf() *ConfigRegister {
|
||||
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)
|
||||
@ -26,19 +36,22 @@ func (c *ConfigRegister) LoadConf() *ConfigRegister {
|
||||
}
|
||||
|
||||
var CommandRegister = make(
|
||||
map[string]func(
|
||||
s *discordgo.Session,
|
||||
m *discordgo.MessageCreate,
|
||||
message string))
|
||||
map[string]Command)
|
||||
|
||||
func SetCommand(aliases []string, command func(
|
||||
s *discordgo.Session,
|
||||
m *discordgo.MessageCreate,
|
||||
message string)) {
|
||||
func SetCommand(
|
||||
aliases []string,
|
||||
desc string,
|
||||
example string,
|
||||
command func(s *discordgo.Session, m *discordgo.MessageCreate, message string)) {
|
||||
for _, alias := range aliases {
|
||||
CommandRegister[alias] = command
|
||||
log.Printf("added %s to Register", alias)
|
||||
c := Command{
|
||||
name: alias,
|
||||
desc: desc,
|
||||
example: example,
|
||||
command: command}
|
||||
CommandRegister[alias] = c
|
||||
log.Printf("added %s to Register", alias)
|
||||
}
|
||||
}
|
||||
|
||||
var Config ConfigRegister
|
||||
var ConfigRegister Config
|
||||
|
||||
Reference in New Issue
Block a user