mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-05-06 14:04:13 +00:00
Tweaked bot router docs
This commit is contained in:
parent
de37b58dd3
commit
1c9b45e051
31
bot/ctx.go
31
bot/ctx.go
|
@ -13,6 +13,21 @@ import (
|
|||
|
||||
// TODO: add variadic arguments
|
||||
|
||||
// Context is the bot state for commands and subcommands.
|
||||
//
|
||||
// A command can be created by making it a method of Commands, or whatever
|
||||
// struct was given to the constructor. This following example creates a command
|
||||
// with a single integer argument (which can be ran with "~example 123"):
|
||||
//
|
||||
// func (c *Commands) Example(m *gateway.MessageCreateEvent, i int) error {
|
||||
// _, err := c.Ctx.SendMessage(m.ChannelID, fmt.Sprintf("You sent: %d", i))
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
// Commands' exported methods will all be used as commands. Messages are parsed
|
||||
// with its first argument (the command) mapped accordingly to c.MapName, which
|
||||
// capitalizes the first letter automatically to reflect the exported method
|
||||
// name.
|
||||
type Context struct {
|
||||
*Subcommand
|
||||
*state.State
|
||||
|
@ -98,22 +113,6 @@ func Wait() {
|
|||
// cmds := &Commands{}
|
||||
// c, err := rfrouter.New(session, cmds)
|
||||
//
|
||||
// Example
|
||||
//
|
||||
// A command can be created by making it a method of Commands, or whatever
|
||||
// struct was given to the constructor. This following example creates a command
|
||||
// with a single integer argument (which can be ran with "~example 123"):
|
||||
//
|
||||
// func (c *Commands) Example(m *gateway.MessageCreateEvent, i int) error {
|
||||
// _, err := c.Ctx.SendMessage(m.ChannelID, fmt.Sprintf("You sent: %d", i))
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
// Commands' exported methods will all be used as commands. Messages are parsed
|
||||
// with its first argument (the command) mapped accordingly to c.MapName, which
|
||||
// capitalizes the first letter automatically to reflect the exported method
|
||||
// name.
|
||||
//
|
||||
// The default prefix is "~", which means commands must start with "~" followed
|
||||
// by the command name in the first argument, else it will be ignored.
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue