- 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
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package bolt
|
|
|
|
import (
|
|
dg "github.com/bwmarrin/discordgo"
|
|
)
|
|
|
|
type Option func(b *bolt)
|
|
type LogLevel 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
|
|
)
|
|
|
|
// 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 full dg.Intent
|
|
for _, i := range intents {
|
|
full |= i
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
// 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
|
|
}
|
|
}
|
|
|
|
// WithLogLevel adjusts bolt logging verbosity
|
|
func WithLogLevel(lvl LogLevel) Option {
|
|
return func(b *bolt) {
|
|
b.logLvl = lvl
|
|
}
|
|
}
|