<commit_before>package bot

import (
	"errors"
	"log"
	"strings"
	"sync"
	"time"

	"golang.org/x/time/rate"

	"github.com/bwmarrin/discordgo"
)

var (
	ErrRateLimitExceeded = errors.New("bot: per-command rate limit exceeded")
)

type Command struct {
	verb     string
	helptext string
}

func (c *Command) Verb() string {
	return c.verb
}

func (c *Command) Helptext() string {
	return c.helptext
}

type Handler func(*discordgo.Session, *discordgo.Message, []string) error

type CommandHandler interface {
	Verb() string
	Helptext() string

	Handler(*discordgo.Session, *discordgo.Message, []string) error
	Permissions(*discordgo.Session, *discordgo.Message, []string) error
}

type basicCommand struct {
	*Command
	handler     Handler
	permissions Handler
	limiter     *rate.Limiter
}

func (bc *basicCommand) Handler(s *discordgo.Session, m *discordgo.Message, parv []string) error {
	return bc.handler(s, m, parv)
}

func (bc *basicCommand) Permissions(s *discordgo.Session, m *discordgo.Message, parv []string) error {
	if !bc.limiter.Allow() {
		return ErrRateLimitExceeded
	}

	return bc.permissions(s, m, parv)
}

var (
	DefaultCommandSet = NewCommandSet()

	ErrAlreadyExists     = errors.New("bot: command already exists")
	ErrNoSuchCommand     = errors.New("bot: no such command exists")
	ErrNoPermissions     = errors.New("bot: you do not have permissions for this command")
	ErrParvCountMismatch = errors.New("bot: parameter count mismatch")
)

const (
	DefaultPrefix = "."
)

// NewCommand creates an anonymous command and adds it to the default CommandSet.
func NewCommand(verb, helptext string, handler, permissions Handler) error {
	return DefaultCommandSet.Add(NewBasicCommand(verb, helptext, handler, permissions))
}

func NewBasicCommand(verb, helptext string, permissions, handler Handler) CommandHandler {
	return &basicCommand{
		Command: &Command{
			verb:     verb,
			helptext: helptext,
		},
		handler:     handler,
		permissions: permissions,
		limiter:     rate.NewLimiter(rate.Every(5*time.Second), 0),
	}
}
<commit_msg>fix that<commit_after>package bot

import (
	"errors"
	"log"
	"strings"
	"sync"
	"time"

	"golang.org/x/time/rate"

	"github.com/bwmarrin/discordgo"
)

var (
	ErrRateLimitExceeded = errors.New("bot: per-command rate limit exceeded")
)

type Command struct {
	verb     string
	helptext string
}

func (c *Command) Verb() string {
	return c.verb
}

func (c *Command) Helptext() string {
	return c.helptext
}

type Handler func(*discordgo.Session, *discordgo.Message, []string) error

type CommandHandler interface {
	Verb() string
	Helptext() string

	Handler(*discordgo.Session, *discordgo.Message, []string) error
	Permissions(*discordgo.Session, *discordgo.Message, []string) error
}

type basicCommand struct {
	*Command
	handler     Handler
	permissions Handler
	limiter     *rate.Limiter
}

func (bc *basicCommand) Handler(s *discordgo.Session, m *discordgo.Message, parv []string) error {
	return bc.handler(s, m, parv)
}

func (bc *basicCommand) Permissions(s *discordgo.Session, m *discordgo.Message, parv []string) error {
	if !bc.limiter.Allow() {
		return ErrRateLimitExceeded
	}

	return bc.permissions(s, m, parv)
}

var (
	DefaultCommandSet = NewCommandSet()

	ErrAlreadyExists     = errors.New("bot: command already exists")
	ErrNoSuchCommand     = errors.New("bot: no such command exists")
	ErrNoPermissions     = errors.New("bot: you do not have permissions for this command")
	ErrParvCountMismatch = errors.New("bot: parameter count mismatch")
)

const (
	DefaultPrefix = "."
)

// NewCommand creates an anonymous command and adds it to the default CommandSet.
func NewCommand(verb, helptext string, handler, permissions Handler) error {
	return DefaultCommandSet.Add(NewBasicCommand(verb, helptext, handler, permissions))
}

func NewBasicCommand(verb, helptext string, permissions, handler Handler) CommandHandler {
	return &basicCommand{
		Command: &Command{
			verb:     verb,
			helptext: helptext,
		},
		handler:     handler,
		permissions: permissions,
		limiter:     rate.NewLimiter(rate.Every(5*time.Second), 1),
	}
}

{'fraction_non_alphanumeric': 0.11385291961886147, 'fraction_numerical': 0.0009772782799902272, 'mean_word_length': 4.623626373626373, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7602644', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1353, 'n_words': 361}