Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = &commands.YAGCommand{ Cooldown: 5, CmdCategory: commands.CategoryFun, Name: "DadJoke", Description: "Generates a dad joke using the API from icanhazdadjoke.", DefaultEnabled: true, SlashCommandEnabled: true, RunFunc: func(data *dcmd.Data) (interface{}, error) { req, err := http.NewRequest("GET", "https://icanhazdadjoke.com", nil) if err != nil { return nil, err } req.Header.Set("Accept", "application/json") req.Header.Add("User-Agent", "YAGPDB.xyz (https://github.com/botlabs-gg/yagpdb)") apiResp, err := http.DefaultClient.Do(req) if err != nil { return nil, err } defer apiResp.Body.Close() bytes, err := io.ReadAll(apiResp.Body) if err != nil { return nil, err } var joke Joke err = json.Unmarshal(bytes, &joke) if err != nil { return nil, err } resp := joke.Joke return resp, nil }, }
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.