[chore] comments and function scope

- methods no longer exported if not used
- readme update
- comments updated
This commit is contained in:
2025-06-08 02:26:06 -04:00
parent 9ffab89ebf
commit 08ffade13d
3 changed files with 35 additions and 17 deletions

10
bolt.go
View File

@@ -26,7 +26,7 @@ const (
// basic bot structure containing discordgo connection as well as the command map
type bolt struct {
*dg.Session //holds discordgo internals
Commands map[string]Command //maps trigger phrase to command struct for fast lookup
commands map[string]Command //maps trigger phrase to command struct for fast lookup
indicator string //the indicator used to detect whether a message is a command
}
@@ -62,7 +62,7 @@ func New(opts ...Option) Bolt {
b := &bolt{
Session: bot,
Commands: make(map[string]Command, 0),
commands: make(map[string]Command, 0),
}
//set default command indicator
b.indicator = "."
@@ -106,7 +106,7 @@ func (b *bolt) stop() error {
// adds commands to bot command map for use
func (b *bolt) AddCommands(cmd ...Command) {
for _, c := range cmd {
b.Commands[c.Trigger] = c
b.commands[c.Trigger] = c
}
}
@@ -152,7 +152,7 @@ func (b *bolt) messageHandler(s *dg.Session, msg *dg.MessageCreate) {
// parses command from message and handles timeout checks, role checks, and command execution. All command responses are sent back to Discord
func (b *bolt) handleCommand(msg *dg.MessageCreate, s *dg.Session, server *dg.Guild, channel *dg.Channel, lg int) error {
words := strings.Split(msg.Content, " ")
run, ok := b.Commands[words[0][lg:]]
run, ok := b.commands[words[0][lg:]]
if !ok {
return nil //command doesn't exist, maybe log or respond to author
}
@@ -201,7 +201,7 @@ func (b *bolt) handleCommand(msg *dg.MessageCreate, s *dg.Session, server *dg.Gu
//update run time
run.lastRun = time.Now()
b.Commands[run.Trigger] = run
b.commands[run.Trigger] = run
return nil
}