Fix XKCD command after new go-xkcd broke it.
parent
c5b91113a3
commit
c2142bb741
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"github.com/bwmarrin/disgord/x/mux"
|
||||
|
@ -103,12 +104,14 @@ func getXKCD(s *discordgo.Session, m *discordgo.Message, ctx *mux.Context) {
|
|||
}
|
||||
matchedNum, _ := regexp.MatchString(`[0-9]+`, arg)
|
||||
if arg == "latest" {
|
||||
comic, err = xkclient.Latest()
|
||||
comic, err = xkclient.Latest(context.Background())
|
||||
} else if matchedNum {
|
||||
comicNum, _ := strconv.Atoi(arg)
|
||||
comic, err = xkclient.Get(comicNum)
|
||||
comic, err = xkclient.Get(context.Background(), comicNum)
|
||||
} else {
|
||||
comic, err = xkclient.Random()
|
||||
latestcomic, _ := xkclient.Latest(context.Background())
|
||||
randcomic := rand.Intn(latestcomic.Number)
|
||||
comic, err = xkclient.Get(context.Background(), randcomic)
|
||||
}
|
||||
if err != nil {
|
||||
resp = err.Error()
|
||||
|
|
Loading…
Reference in New Issue