2025-06-04 18:28:27 -04:00
|
|
|
package bolt
|
|
|
|
|
|
2026-02-24 16:54:25 -05:00
|
|
|
import (
|
|
|
|
|
dg "github.com/bwmarrin/discordgo"
|
|
|
|
|
)
|
|
|
|
|
|
2025-06-04 18:28:27 -04:00
|
|
|
type Option func(b *bolt)
|
|
|
|
|
|
2025-06-25 22:51:32 +00:00
|
|
|
type LogLevel int
|
|
|
|
|
|
2026-02-24 16:54:25 -05:00
|
|
|
type Permission dg.Intent
|
|
|
|
|
|
|
|
|
|
type HandlerLevel int
|
|
|
|
|
|
2025-06-25 22:51:32 +00:00
|
|
|
const (
|
2026-02-24 16:54:25 -05:00
|
|
|
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.
|
2025-06-25 22:51:32 +00:00
|
|
|
)
|
|
|
|
|
|
2026-02-24 16:54:25 -05:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-04 18:28:27 -04:00
|
|
|
// 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) {
|
|
|
|
|
b.indicator = i
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-25 22:51:32 +00:00
|
|
|
|
|
|
|
|
// sets the log level to determine how much bolt logs
|
|
|
|
|
func WithLogLevel(lvl LogLevel) Option {
|
|
|
|
|
return func(b *bolt) {
|
|
|
|
|
b.logLvl = lvl
|
|
|
|
|
}
|
|
|
|
|
}
|