2020-06-09 13:04:44 +00:00
|
|
|
package discord
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"go.etztech.xyz/sedbot/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Links(cfg *config.Config) {
|
|
|
|
links := make([]string, 0)
|
|
|
|
for _, link := range cfg.Links {
|
|
|
|
commands[link.Name] = command{
|
|
|
|
validate: func(cmd commandInit) bool {
|
|
|
|
return true
|
|
|
|
},
|
2020-06-12 05:17:58 +00:00
|
|
|
run: func(cmd commandInit) (string, error) {
|
|
|
|
return fmt.Sprintf("<%s>", link.URL), nil
|
2020-06-09 13:04:44 +00:00
|
|
|
},
|
|
|
|
help: fmt.Sprintf("Returns the link for %s", link.Name),
|
|
|
|
}
|
2020-06-12 05:17:58 +00:00
|
|
|
links = append(links, fmt.Sprintf("%s -> <%s>", link.Name, link.URL))
|
2020-06-09 13:04:44 +00:00
|
|
|
for _, alias := range link.Aliases {
|
|
|
|
commands[alias] = command{
|
|
|
|
validate: func(cmd commandInit) bool {
|
|
|
|
return true
|
|
|
|
},
|
2020-06-12 05:17:58 +00:00
|
|
|
run: func(cmd commandInit) (string, error) {
|
|
|
|
return fmt.Sprintf("<%s>", link.URL), nil
|
2020-06-09 13:04:44 +00:00
|
|
|
},
|
|
|
|
help: fmt.Sprintf("Returns the link for %s", alias),
|
|
|
|
}
|
2020-06-12 05:17:58 +00:00
|
|
|
links = append(links, fmt.Sprintf("%s -> <%s>", alias, link.URL))
|
2020-06-09 13:04:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commands["links"] = command{
|
|
|
|
validate: func(cmd commandInit) bool {
|
|
|
|
return true
|
|
|
|
},
|
2020-06-12 05:17:58 +00:00
|
|
|
run: func(cmd commandInit) (string, error) {
|
|
|
|
return strings.Join(links, "\n"), nil
|
2020-06-09 13:04:44 +00:00
|
|
|
},
|
|
|
|
help: "Get all dynamic links",
|
|
|
|
}
|
|
|
|
}
|