forked from Minecraft/canopeas
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
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
|
|
},
|
|
run: func(cmd commandInit) (string, error) {
|
|
return fmt.Sprintf("<%s>", link.URL), nil
|
|
},
|
|
help: fmt.Sprintf("Returns the link for %s", link.Name),
|
|
}
|
|
links = append(links, fmt.Sprintf("%s -> <%s>", link.Name, link.URL))
|
|
for _, alias := range link.Aliases {
|
|
commands[alias] = command{
|
|
validate: func(cmd commandInit) bool {
|
|
return true
|
|
},
|
|
run: func(cmd commandInit) (string, error) {
|
|
return fmt.Sprintf("<%s>", link.URL), nil
|
|
},
|
|
help: fmt.Sprintf("Returns the link for %s", alias),
|
|
}
|
|
links = append(links, fmt.Sprintf("%s -> <%s>", alias, link.URL))
|
|
}
|
|
}
|
|
|
|
commands["links"] = command{
|
|
validate: func(cmd commandInit) bool {
|
|
return true
|
|
},
|
|
run: func(cmd commandInit) (string, error) {
|
|
return strings.Join(links, "\n"), nil
|
|
},
|
|
help: "Get all dynamic links",
|
|
}
|
|
}
|