comcord/commands/help.go

43 lines
879 B
Go
Raw Normal View History

2023-07-08 20:51:26 +00:00
package commands
import (
"fmt"
"strings"
2023-07-09 04:42:58 +00:00
"github.com/Cynosphere/comcord/state"
2023-07-08 20:51:26 +00:00
"github.com/bwmarrin/discordgo"
2023-07-09 04:42:58 +00:00
"github.com/mgutz/ansi"
2023-07-08 20:51:26 +00:00
)
2023-07-09 04:42:58 +00:00
const format string = " %s - %s%s"
2023-07-08 20:51:26 +00:00
func HelpCommand(session *discordgo.Session) {
2023-07-09 04:42:58 +00:00
noColor := state.HasNoColor()
2023-07-08 20:51:26 +00:00
fmt.Println("\r\nCOMcord (c)left 2023\n\r")
index := 0
for key, cmd := range GetAllCommands() {
2023-07-09 04:42:58 +00:00
str := fmt.Sprintf(format, key, cmd.Description, "")
2023-07-08 20:51:26 +00:00
length := len(str)
2023-07-09 04:42:58 +00:00
padding := strings.Repeat(" ", 25 - length)
2023-07-08 20:51:26 +00:00
2023-07-09 04:42:58 +00:00
if noColor {
fmt.Printf(format, key, cmd.Description, padding)
} else {
coloredKey := ansi.Color(key, "yellow+b")
fmt.Printf(format, coloredKey, cmd.Description, padding)
}
2023-07-08 20:51:26 +00:00
index++
if index % 3 == 0 {
fmt.Print("\n\r")
}
}
if index % 3 != 0 {
fmt.Print("\n\r")
}
fmt.Println("\r\nTo begin TALK MODE, press [SPACE]\n\r")
}