Show aliases in help command

This commit is contained in:
Michał Gdula 2025-05-12 00:27:36 +01:00
parent e8f6e7cc0a
commit efcba1f555
2 changed files with 18 additions and 4 deletions

View file

@ -132,8 +132,19 @@ func (b *Bot) handler(session *discordgo.Session, message *discordgo.MessageCrea
func printHelp(bot *Bot, h *Handler) { func printHelp(bot *Bot, h *Handler) {
var commands []string var commands []string
for cmd := range bot.commands { for command := range bot.commands {
commands = append(commands, cmd) var found []string
for a, c := range bot.aliases {
if c == command {
found = append(found, a)
}
}
if len(found) > 0 {
commands = append(commands, fmt.Sprintf("%s (%s)", command, strings.Join(found, ", ")))
} else {
commands = append(commands, command)
}
} }
_, _ = h.Session.ChannelMessageSendComplex(h.Message.ChannelID, &discordgo.MessageSend{ _, _ = h.Session.ChannelMessageSendComplex(h.Message.ChannelID, &discordgo.MessageSend{
@ -141,6 +152,9 @@ func printHelp(bot *Bot, h *Handler) {
Title: "Help", Title: "Help",
Description: strings.Join(commands, "\n"), Description: strings.Join(commands, "\n"),
Color: color.RGBToDiscord(255, 255, 255), Color: color.RGBToDiscord(255, 255, 255),
Footer: &discordgo.MessageEmbedFooter{
Text: "command (aliases...)",
},
}, },
Reference: h.Reference, Reference: h.Reference,
}) })

View file

@ -76,7 +76,7 @@ func registerSaveable(bot *handler.Bot) handler.Callback {
Image: &discordgo.MessageEmbedImage{ Image: &discordgo.MessageEmbedImage{
URL: "attachment://saveable.gif", URL: "attachment://saveable.gif",
}, },
Color: color.RGBToDiscord(1, 1, 1), Color: color.RGBToDiscord(255, 255, 255),
}, },
Files: []*discordgo.File{ Files: []*discordgo.File{
{ {
@ -205,7 +205,7 @@ func registerCaption(bot *handler.Bot) handler.Callback {
Image: &discordgo.MessageEmbedImage{ Image: &discordgo.MessageEmbedImage{
URL: "attachment://caption.jpeg", URL: "attachment://caption.jpeg",
}, },
Color: color.RGBToDiscord(1, 1, 1), Color: color.RGBToDiscord(255, 255, 255),
}, },
Files: []*discordgo.File{ Files: []*discordgo.File{
{ {