WIP
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:
43
option.go
43
option.go
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user