package example
import (
"fmt"
"strconv"
"encoding/json"
"PLuginExample/plugins"
)
type ExampleInts struct {
IntA int `json:"intA"`
IntB int `json:"intB"`
}
func add(firstNo int, secondNo int)string {
result := strconv.Itoa( firstNo + secondNo )
return result
}
func init() {
var commands plugins.Command
commands.Name = "!add"
commands.Callback = func(args ...interface{})(string) {
var ints ExampleInts
jsonToUse := []byte(args[0].(string))
err := json.Unmarshal(jsonToUse, &ints)
if err != nil {
fmt.Println(err.Error())
}
result := add(ints.IntA, ints.IntB)
return result
}
var p plugins.PluginInfo
p.Name = "Example Addition"
p.About = "Example plugin to add two numbers together"
p.Commands = commands
p.AddPluginInfo()
}