readme and comments
This commit is contained in:
parent
6aeb64be75
commit
dc25c6e3ec
49
README.md
49
README.md
@ -5,5 +5,54 @@ Base Discord bot framework
|
||||
## 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 is 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.
|
||||
|
||||
## Basic Usage
|
||||
bolt allows developers to create a Discord bot with simply a discord bot token and a few lines of Go code, the below example creates a Discord bot and registers two commands: ".test" and ".time"
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"code.jakeyoungdev.com/jake/bolt"
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
)
|
||||
|
||||
func main() {
|
||||
b := bolt.New()
|
||||
|
||||
b.AddCommands(
|
||||
bolt.Command{
|
||||
Trigger: ".test",
|
||||
Payload: func(msg bolt.Message) (res string, err error) {
|
||||
return "nah", nil //any strings returned will be sent in response to the Discord message
|
||||
},
|
||||
},
|
||||
bolt.Command{
|
||||
Trigger: ".time",
|
||||
Payload: func(msg bolt.Message) (res string, err error) {
|
||||
return "yer", nil
|
||||
},
|
||||
Timeout: time.Second * 25, //command can only run every 25 seconds
|
||||
},
|
||||
)
|
||||
|
||||
_ = b.Start()
|
||||
|
||||
//set up safe CTRL-C
|
||||
sigChannel := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChannel, syscall.SIGINT)
|
||||
log.Println("bot running")
|
||||
<-sigChannel
|
||||
|
||||
if err := b.Stop(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Development
|
||||
bolt is in heavy development at the moment and may break occasionally before a v1 release, it is currently in a testing phase and should not be used until tagged.
|
6
bolt.go
6
bolt.go
@ -13,12 +13,6 @@ import (
|
||||
const (
|
||||
TOKEN_ENV_VAR = "DISCORD_TOKEN" //label for token environment variable
|
||||
|
||||
// BOT_INTENTS = dg.IntentsAllWithoutPrivileged |
|
||||
// dg.IntentGuildMembers |
|
||||
// dg.IntentGuildPresences |
|
||||
// dg.IntentMessageContent |
|
||||
// dg.IntentsGuildMessages
|
||||
|
||||
BOT_INTENTS = dg.IntentGuildMembers |
|
||||
dg.IntentGuildPresences |
|
||||
dg.IntentMessageContent |
|
||||
|
Loading…
x
Reference in New Issue
Block a user