|
@@ -59,6 +59,10 @@ func (r *Router) helpCommandHandler(s *discordgo.Session, m *discordgo.Message,
|
|
|
keys := make([]string, 0, len(r.routes))
|
|
|
for _, route := range r.routes {
|
|
|
if route.CategoryID == 0 {
|
|
|
+ if route.Admin && !isAdmin {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
l := len(route.Usage) // TODO: Add the +args part :)
|
|
|
if l > maxDisplayLen {
|
|
|
maxDisplayLen = l
|
|
@@ -88,23 +92,27 @@ func (r *Router) helpCommandHandler(s *discordgo.Session, m *discordgo.Message,
|
|
|
maxDisplayLen = maxDisplayLen + 3
|
|
|
|
|
|
// TODO: Learn more link needs to be configurable
|
|
|
- resp := "```autoit\n"
|
|
|
+ innerResp := ""
|
|
|
|
|
|
// Add sorted result to help msg
|
|
|
for _, catKey := range cats {
|
|
|
if catKey != "" {
|
|
|
- resp += fmt.Sprintf("\n%s\n", catKey)
|
|
|
+ innerResp += fmt.Sprintf("\n%s\n", catKey)
|
|
|
} else {
|
|
|
- resp += "\n\n"
|
|
|
+ innerResp += "\n\n"
|
|
|
}
|
|
|
|
|
|
routes := catMap[catKey]
|
|
|
for _, routeKey := range routes {
|
|
|
route := cmdmap[routeKey]
|
|
|
- resp += fmt.Sprintf("%s%-"+strconv.Itoa(maxDisplayLen)+"s # %s\n", displayPrefix, route.Usage, route.Description)
|
|
|
+ innerResp += fmt.Sprintf("%s%-"+strconv.Itoa(maxDisplayLen)+"s # %s\n", displayPrefix, route.Usage, route.Description)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- resp += "```\n"
|
|
|
+ if innerResp == "" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := "```autoit\n" + innerResp + "```\n"
|
|
|
s.ChannelMessageSend(m.ChannelID, resp)
|
|
|
}
|