<commit_before>package information

import (
	"errors"
	"sort"
	"strings"

	"Fantasia/system"

	"github.com/Necroforger/dream"
	"github.com/bwmarrin/discordgo"
)

// Module ...
type Module struct{}

// Build adds this modules commands to the system's router
func (m *Module) Build(s *system.System) {
	r := s.CommandRouter
	r.On("help", m.Help).Set("", "Displays a help menu with the available commands")
}

// CategoriesBySize sorts categories by size
type CategoriesBySize []*discordgo.MessageEmbedField

// Size ...
func (c CategoriesBySize) Size() int {
	return len(c)
}

// Len ...
func (c CategoriesBySize) Len() int {
	return len(c)
}

// Less ...
func (c CategoriesBySize) Less(a, b int) bool {
	return len(c[a].Value) < len(c[b].Value)
}

// Swap ...
func (c CategoriesBySize) Swap(a, b int) {
	c[a], c[b] = c[b], c[a]
}

// Help maps a list of available commands and descends into subrouters.
func (m *Module) Help(ctx *system.Context) {

	if cmd := ctx.Args.After(); cmd != "" {
		if route, _ := ctx.System.CommandRouter.FindMatch(cmd); route != nil {
			ctx.ReplyEmbed(dream.NewEmbed().
				SetTitle(route.Name).
				SetDescription(route.Desc).
				SetColor(system.StatusNotify).
				MessageEmbed)
			return
		}
		ctx.ReplyError(errors.New("Command not found"))
		return
	}

	embed := depthcharge(ctx.System.CommandRouter, nil, 0)

	for _, v := range embed.Fields {
		v.Value = "```" + v.Value + "```"
	}

	sort.Sort(sort.Reverse(CategoriesBySize(embed.Fields)))

	_, err := ctx.ReplyEmbed(embed.
		SetColor(system.StatusNotify).
		// SetThumbnail(ctx.Ses.DG.State.User.AvatarURL("512")).
		InlineAllFields().
		SetDescription("`Bot prefix: " + ctx.System.Config.Prefix + "` type `help [command]` for more information\nCommands separated with `|` represent alternative names.\nIndented commands are subroutes of their parent commands").
		MessageEmbed)
	if err != nil {
		ctx.ReplyError(err)
	}
}<commit_msg>Fixed help menu not showing the first command in a category<commit_after>package information

import (
	"errors"
	"sort"
	"strings"

	"Fantasia/system"

	"github.com/Necroforger/dream"
	"github.com/bwmarrin/discordgo"
)

// Module ...
type Module struct{}

// Build adds this modules commands to the system's router
func (m *Module) Build(s *system.System) {
	r := s.CommandRouter
	r.On("help", m.Help).Set("", "Displays a help menu with the available commands")
}

// CategoriesBySize sorts categories by size
type CategoriesBySize []*discordgo.MessageEmbedField

// Size ...
func (c CategoriesBySize) Size() int {
	return len(c)
}

// Len ...
func (c CategoriesBySize) Len() int {
	return len(c)
}

// Less ...
func (c CategoriesBySize) Less(a, b int) bool {
	return len(c[a].Value) < len(c[b].Value)
}

// Swap ...
func (c CategoriesBySize) Swap(a, b int) {
	c[a], c[b] = c[b], c[a]
}

// Help maps a list of available commands and descends into subrouters.
func (m *Module) Help(ctx *system.Context) {

	if cmd := ctx.Args.After(); cmd != "" {
		if route, _ := ctx.System.CommandRouter.FindMatch(cmd); route != nil {
			ctx.ReplyEmbed(dream.NewEmbed().
				SetTitle(route.Name).
				SetDescription(route.Desc).
				SetColor(system.StatusNotify).
				MessageEmbed)
			return
		}
		ctx.ReplyError(errors.New("Command not found"))
		return
	}

	embed := depthcharge(ctx.System.CommandRouter, nil, 0)

	for _, v := range embed.Fields {
		v.Value = "```\n" + v.Value + "```"
	}

	sort.Sort(sort.Reverse(CategoriesBySize(embed.Fields)))

	_, err := ctx.ReplyEmbed(embed.
		SetColor(system.StatusNotify).
		// SetThumbnail(ctx.Ses.DG.State.User.AvatarURL("512")).
		InlineAllFields().
		SetDescription("`Bot prefix: " + ctx.System.Config.Prefix + "` type `help [command]` for more information\nCommands separated with `|` represent alternative names.\nIndented commands are subroutes of their parent commands").
		MessageEmbed)
	if err != nil {
		ctx.ReplyError(err)
	}
}
{'fraction_non_alphanumeric': 0.15560699588477367, 'fraction_numerical': 0.00205761316872428, 'mean_word_length': 3.8370646766169156, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7385749', 'n_tokens_mistral': 1443, 'n_tokens_neox': 1341, 'n_words': 335}