From a6bf7c340b1de7adcde280c9fbec0947c7a0388b Mon Sep 17 00:00:00 2001 From: "diamondburned (Forefront)" Date: Sun, 19 Jan 2020 17:58:24 -0800 Subject: [PATCH] Added example into bot/Context's doc --- bot/ctx.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bot/ctx.go b/bot/ctx.go index 89641ed..7ac4c81 100644 --- a/bot/ctx.go +++ b/bot/ctx.go @@ -98,6 +98,17 @@ 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