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...) echoes = append(echoes, fmt.Sprintf("%s: %s", strings.Join(combined, ", "), echo.Help)) } 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", } }