2025-06-04 18:28:27 -04:00
|
|
|
package bolt
|
|
|
|
|
|
2026-02-24 16:54:25 -05:00
|
|
|
import (
|
|
|
|
|
dg "github.com/bwmarrin/discordgo"
|
|
|
|
|
)
|
|
|
|
|
|
2026-05-21 17:52:36 -04:00
|
|
|
type Option func(b *Bolt)
|
2025-06-25 22:51:32 +00:00
|
|
|
type LogLevel int
|
|
|
|
|
|
|
|
|
|
const (
|
2026-02-25 13:24:27 -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
|
2025-06-25 22:51:32 +00:00
|
|
|
)
|
|
|
|
|
|
2026-02-25 13:24:27 -05:00
|
|
|
// 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 {
|
2026-05-21 17:52:36 -04:00
|
|
|
return func(b *Bolt) {
|
2026-02-25 13:24:27 -05:00
|
|
|
var full dg.Intent
|
|
|
|
|
for _, i := range intents {
|
|
|
|
|
full |= i
|
2026-02-24 16:54:25 -05:00
|
|
|
}
|
|
|
|
|
|
2026-02-25 13:24:27 -05:00
|
|
|
b.Identify.Intents = full
|
2026-02-24 16:54:25 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-25 13:24:27 -05:00
|
|
|
// 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
|
2026-02-24 16:54:25 -05:00
|
|
|
func WithMaxGoroutines(max int) Option {
|
2026-05-21 17:52:36 -04:00
|
|
|
return func(b *Bolt) {
|
2026-02-24 16:54:25 -05:00
|
|
|
b.maxRoutines = max
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-25 13:24:27 -05:00
|
|
|
// WithIndicator sets the substring that must be present at the beginning of a message to trigger a
|
|
|
|
|
// command, for example "." or "!"
|
2025-06-04 18:28:27 -04:00
|
|
|
func WithIndicator(i string) Option {
|
2026-05-21 17:52:36 -04:00
|
|
|
return func(b *Bolt) {
|
2025-06-04 18:28:27 -04:00
|
|
|
b.indicator = i
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-25 22:51:32 +00:00
|
|
|
|
2026-02-25 13:24:27 -05:00
|
|
|
// WithLogLevel adjusts bolt logging verbosity
|
2025-06-25 22:51:32 +00:00
|
|
|
func WithLogLevel(lvl LogLevel) Option {
|
2026-05-21 17:52:36 -04:00
|
|
|
return func(b *Bolt) {
|
2025-06-25 22:51:32 +00:00
|
|
|
b.logLvl = lvl
|
|
|
|
|
}
|
|
|
|
|
}
|