Files
bolt/option.go
jake 01dd3633ef adding Context
- converting messages and methods into one context per event
2026-02-24 18:45:00 -05:00

67 lines
1.4 KiB
Go

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 //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.
)
func WithPermissions(perms ...Permission) Option {
return func(b *bolt) {
var fullPerms dg.Intent
for _, p := range perms {
// if p == AdminPermissions {
// b.admin = true
// }
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) {
b.indicator = i
}
}
// sets the log level to determine how much bolt logs
func WithLogLevel(lvl LogLevel) Option {
return func(b *bolt) {
b.logLvl = lvl
}
}