readme update
This commit is contained in:
parent
dc25c6e3ec
commit
381073dc39
15
README.md
15
README.md
@ -3,7 +3,7 @@
|
|||||||
Base Discord bot framework
|
Base Discord bot framework
|
||||||
|
|
||||||
## 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 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.
|
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. Any strings returned from the Payload function will be sent back to the Discord server as a reply to the command message.
|
||||||
|
|
||||||
## Basic Usage
|
## 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"
|
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"
|
||||||
@ -25,19 +25,30 @@ func main() {
|
|||||||
b := bolt.New()
|
b := bolt.New()
|
||||||
|
|
||||||
b.AddCommands(
|
b.AddCommands(
|
||||||
|
// .test can be run at any time by anyone
|
||||||
bolt.Command{
|
bolt.Command{
|
||||||
Trigger: ".test",
|
Trigger: ".test",
|
||||||
Payload: func(msg bolt.Message) (res string, err error) {
|
Payload: func(msg bolt.Message) (res string, err error) {
|
||||||
return "nah", nil //any strings returned will be sent in response to the Discord message
|
return "nah", nil //any strings returned will be sent in response to the Discord message
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// .time can be run every 25 seconds by anyone
|
||||||
bolt.Command{
|
bolt.Command{
|
||||||
Trigger: ".time",
|
Trigger: ".time",
|
||||||
Payload: func(msg bolt.Message) (res string, err error) {
|
Payload: func(msg bolt.Message) (res string, err error) {
|
||||||
return "yer", nil
|
return "yer", nil
|
||||||
},
|
},
|
||||||
Timeout: time.Second * 25, //command can only run every 25 seconds
|
Timeout: time.Second * 25,
|
||||||
},
|
},
|
||||||
|
// .role can be run every 10 seconds by anyone with the 'admin' role
|
||||||
|
bolt.Command{
|
||||||
|
Trigger: ".role",
|
||||||
|
Payload: func(msg bolt.Message) (res string, err error) {
|
||||||
|
return "hi", nil
|
||||||
|
},
|
||||||
|
Timeout: time.Second * 10,
|
||||||
|
Roles: []string{"admin"}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
_ = b.Start()
|
_ = b.Start()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user