Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = &commands.YAGCommand{ CmdCategory: commands.CategoryFun, Name: "Xkcd", Description: "An xkcd comic, by default returns random comic strip", Arguments: []*dcmd.ArgDef{ &dcmd.ArgDef{Name: "Comic number", Type: dcmd.Int}, }, ArgSwitches: []*dcmd.ArgDef{ &dcmd.ArgDef{Switch: "l", Name: "Latest comic"}, }, RunFunc: func(data *dcmd.Data) (interface{}, error) { latest := false xkcd, err := getComic() if err != nil { return "Something happened whilst getting the comic!", err } xkcdNum := rand.Int63n(xkcd.Num) + 1 if data.Switches["l"].Value != nil && data.Switches["l"].Value.(bool) { latest = true } if data.Args[0].Value != nil { n := data.Args[0].Int64() if n >= 1 && n <= xkcd.Num { xkcdNum = n } else { return fmt.Sprintf("There's no comic numbered %d, current range is 1-%d", n, xkcd.Num), nil } } if !latest { xkcd, err = getComic(xkcdNum) if err != nil { return "Something happened whilst getting the comic!", err } } embed := &discordgo.MessageEmbed{ Title: fmt.Sprintf("#%d: %s", xkcd.Num, xkcd.Title), Description: fmt.Sprintf("[%s](%s%d/)", xkcd.Alt, XkcdHost, xkcd.Num), Color: int(rand.Int63n(16777215)), Image: &discordgo.MessageEmbedImage{ URL: xkcd.Img, }, } return embed, nil }, }
View Source
var XkcdHost = "https://xkcd.com/"
View Source
var XkcdJson = "info.0.json"
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.