2 Commits

Author SHA1 Message Date
0b39a0996f Update README.md 2025-06-07 13:41:19 +00:00
9ffab89ebf adding TODO comments 2025-06-07 09:31:00 -04:00
2 changed files with 5 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
# bolt # bolt
Base Discord bot framework Base library for Discord bots
## Introduction ## Introduction
bolt is a wrapper for Discordgo to provide very quick and easy setup for simple Discord bots. The only code required to run bolt are the command handler functions, this provides developers with the ability to have text-based commands on a Discord server without all the bootstrapping and setup usually required. Any strings returned from the Payload function will be sent back to the Discord server as a reply to the command message. bolt is a wrapper for Discordgo to provide very quick and easy setup for simple Discord bots. The only code required to run bolt are the command handler functions, this provides developers with the ability to have text-based commands on a Discord server without all the bootstrapping and setup usually required. Any strings returned from the Payload function will be sent back to the Discord server as a reply to the command message.

View File

@@ -67,6 +67,7 @@ func New(opts ...Option) Bolt {
//set default command indicator //set default command indicator
b.indicator = "." b.indicator = "."
//apply options to bolt
for _, o := range opts { for _, o := range opts {
o(b) o(b)
} }
@@ -85,6 +86,7 @@ func (b *bolt) Start() error {
return err return err
} }
//safe shutdown handler
sigChannel := make(chan os.Signal, 1) sigChannel := make(chan os.Signal, 1)
signal.Notify(sigChannel, syscall.SIGINT) signal.Notify(sigChannel, syscall.SIGINT)
<-sigChannel <-sigChannel
@@ -241,7 +243,8 @@ func (b *bolt) getRemainingTimeout(timeout time.Time) string {
// checks if the author of msg has the correct role to run the requested command // checks if the author of msg has the correct role to run the requested command
func (b *bolt) roleCheck(msg *dg.MessageCreate, s *dg.Session, run Command) (bool, error) { func (b *bolt) roleCheck(msg *dg.MessageCreate, s *dg.Session, run Command) (bool, error) {
var found bool var found bool
//loop thru author roles //loop thru author roles, there may be a better way to check for this UNION
//TODO: improve role search performance to support bigger lists
for _, r := range msg.Member.Roles { for _, r := range msg.Member.Roles {
//get role name from ID //get role name from ID
n, err := s.State.Role(msg.GuildID, r) n, err := s.State.Role(msg.GuildID, r)