[chore] cleaning

- removing old or commented code
- removing unused or deprecated types
- commenting everything, probably too much
- split msgEventHandler logic into methods
- readme update, removed most docs the pkg site looks good
- adjusted intents option, no need for a type
This commit is contained in:
2026-02-25 13:24:27 -05:00
parent 4732e94c1b
commit b9c26c6319
6 changed files with 191 additions and 215 deletions

View File

@@ -5,60 +5,44 @@ import (
)
type Option func(b *bolt)
type LogLevel int
type Permission dg.Intent
type HandlerLevel int
const (
LogLevelAll LogLevel = iota //log all messages, and errors
LogLevelCmd LogLevel = iota //log only commands and responses, and errors
LogLevelErr LogLevel = iota //log only errors
LogLevelNone LogLevel = iota //log nothing, let the handlers sort it out
msgPerms dg.Intent = dg.IntentGuilds |
dg.IntentGuildMembers |
dg.IntentGuildPresences |
dg.IntentMessageContent |
dg.IntentsGuildMessages |
dg.IntentGuildMessageReactions
MessagePermissions Permission = Permission(msgPerms)
AdminPermissions Permission = 0 //fake
//we also need a ModeratorPermissions for banning, kicking, etc.
LogLevelAll LogLevel = iota //log all messages, and errors
LogLevelCmd LogLevel = iota //log only commands and responses, and errors
LogLevelErr LogLevel = iota //log only errors
)
func WithPermissions(perms ...Permission) Option {
// WithIntents provides an option to use custom intents for the bot. Bolt comes preconfigured with the basic
// intents needed to run a bot but those are completely overwritten by any supplied here
func WithIntents(intents ...dg.Intent) Option {
return func(b *bolt) {
var fullPerms dg.Intent
for _, p := range perms {
// if p == AdminPermissions {
// b.admin = true
// }
fullPerms |= dg.Intent(p)
var full dg.Intent
for _, i := range intents {
full |= i
}
//set intents
b.Identify.Intents = fullPerms
b.Identify.Intents = full
}
}
// WithMaxGoroutines limits the amount of handler routines the bot is able to spawn at the same time. A lower value
// may cause higher latency but may reduce resources needed to run bolt
func WithMaxGoroutines(max int) Option {
return func(b *bolt) {
b.maxRoutines = max
}
}
// sets the substring that must be present at the beginning of the message to indicate a command
// WithIndicator sets the substring that must be present at the beginning of a message to trigger a
// command, for example "." or "!"
func WithIndicator(i string) Option {
return func(b *bolt) {
b.indicator = i
}
}
// sets the log level to determine how much bolt logs
// WithLogLevel adjusts bolt logging verbosity
func WithLogLevel(lvl LogLevel) Option {
return func(b *bolt) {
b.logLvl = lvl