github.com/starshine-sys/bcr@v0.21.0/README.md (about)

     1  # bcr
     2  
     3  A command handler based on [arikawa](https://github.com/diamondburned/arikawa). Mostly for personal use, but feel free to use it elsewhere 🙂
     4  
     5  Package `bot` contains a basic wrapper around `bcr`, for a categorized help command.
     6  
     7  ## Example
     8  
     9  (replace `"token"` with your bot's token, and the user ID with your own ID)
    10  
    11  ```go
    12  // create a router
    13  router, err := bcr.NewWithState("token", []discord.UserID{0}, []string{"~"})
    14  
    15  // make sure to add the message create handler
    16  router.State.AddHandler(router.MessageCreate)
    17  
    18  // add a command
    19  router.AddCommand(&bcr.Command{
    20      Name:    "ping",
    21      Summary: "Ping pong!",
    22  
    23      Command: func(ctx *bcr.Context) (err error) {
    24          _, err = ctx.Send("Pong!", nil)
    25          return
    26      },
    27  })
    28  
    29  // connect to discord
    30  if err := bot.Router.State.Open(); err != nil {
    31      log.Fatalln("Failed to connect:", err)
    32  }
    33  ```