2021-01-09 03:00:28 +00:00
|
|
|
package discord
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"go.etztech.xyz/falseknees"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2021-02-23 05:53:55 +00:00
|
|
|
commands = append(commands, &command{
|
|
|
|
name: "birb",
|
2021-01-09 03:00:28 +00:00
|
|
|
validate: func(cmd commandInit) bool {
|
|
|
|
return true
|
|
|
|
},
|
|
|
|
run: func(cmd commandInit) (string, error) {
|
|
|
|
if !memeRateLimit.Try() {
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
|
|
|
client := falseknees.New()
|
|
|
|
|
|
|
|
var comic *falseknees.Comic
|
|
|
|
var err error
|
|
|
|
args := strings.Fields(cmd.message.Content)
|
|
|
|
if len(args) < 2 {
|
|
|
|
comic, err = client.Random(context.Background())
|
|
|
|
} else if strings.EqualFold(args[1], "new") {
|
|
|
|
comic, err = client.Current(context.Background())
|
|
|
|
} else {
|
|
|
|
comicNum, err := strconv.Atoi(args[1])
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
comic, err = client.Comic(context.Background(), comicNum)
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("%d: %s\n%s", comic.Num, comic.Title, comic.Img), nil
|
|
|
|
},
|
|
|
|
help: "Get a FalseKnees comic",
|
2021-02-23 05:53:55 +00:00
|
|
|
})
|
2021-01-09 03:00:28 +00:00
|
|
|
}
|