2020-06-12 16:38:18 +00:00
|
|
|
package discord
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"go.etztech.xyz/sedbot/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Echo(cfg *config.Config) {
|
|
|
|
echoes := make([]string, 0)
|
|
|
|
for _, e := range cfg.Echoes {
|
|
|
|
echo := e
|
|
|
|
commands[echo.Name] = command{
|
|
|
|
validate: func(cmd commandInit) bool {
|
|
|
|
return true
|
|
|
|
},
|
|
|
|
run: func(cmd commandInit) (string, error) {
|
|
|
|
return echo.Message, nil
|
|
|
|
},
|
|
|
|
help: echo.Help,
|
|
|
|
}
|
|
|
|
for _, a := range echo.Aliases {
|
|
|
|
alias := a
|
|
|
|
commands[alias] = command{
|
|
|
|
validate: func(cmd commandInit) bool {
|
|
|
|
return true
|
|
|
|
},
|
|
|
|
run: func(cmd commandInit) (string, error) {
|
|
|
|
return echo.Message, nil
|
|
|
|
},
|
|
|
|
help: echo.Help,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
combined := append([]string{echo.Name}, echo.Aliases...)
|
2020-07-02 20:00:22 +00:00
|
|
|
echoes = append(echoes, fmt.Sprintf("**%s**: %s", strings.Join(combined, ", "), echo.Help))
|
2020-06-12 16:38:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
commands["echoes"] = command{
|
|
|
|
validate: func(cmd commandInit) bool {
|
|
|
|
return true
|
|
|
|
},
|
|
|
|
run: func(cmd commandInit) (string, error) {
|
|
|
|
return strings.Join(echoes, "\n"), nil
|
|
|
|
},
|
|
|
|
help: "Get all dynamic messages",
|
|
|
|
}
|
|
|
|
}
|