started the facelift of the repo, adding in bans and timeouts. That comes with some restructure.
Also implementing a goroutine limit for command handlers and options around that, as well as moving
the intents to options to allow stronger restrictions
This commit is contained in:
2026-02-24 16:54:25 -05:00
parent c291f68005
commit 6816d7359b
6 changed files with 247 additions and 155 deletions

View File

@@ -1,15 +1,52 @@
package bolt
import (
dg "github.com/bwmarrin/discordgo"
)
type Option func(b *bolt)
type LogLevel int
type Permission dg.Intent
type HandlerLevel int
const (
LogLevelAll LogLevel = iota //logs all messages, and errors
LogLevelCmd LogLevel = iota //log only commands and responses, and errors
LogLevelErr LogLevel = iota //logs only errors
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
MessagePermissions Permission = Permission(msgPerms)
ReactionPermissions Permission = Permission(dg.IntentGuildMessageReactions)
//we also need a ModeratorPermissions for banning, kicking, etc.
)
func WithPermissions(perms ...Permission) Option {
return func(b *bolt) {
var fullPerms dg.Intent
for _, p := range perms {
fullPerms |= dg.Intent(p)
}
//set intents
b.Identify.Intents = fullPerms
}
}
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
func WithIndicator(i string) Option {
return func(b *bolt) {