forked from ImpactDevelopment/ImpactBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunny.go
More file actions
33 lines (30 loc) · 722 Bytes
/
funny.go
File metadata and controls
33 lines (30 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"errors"
"net/http"
"github.com/PuerkitoBio/goquery"
"github.com/bwmarrin/discordgo"
)
func handleFunny(_ *discordgo.Member, msg *discordgo.Message, _ []string) error {
resp, err := http.Get("https://ifunny.co/feeds/shuffle")
if err != nil {
return err
}
doc, err := goquery.NewDocumentFromResponse(resp)
if err != nil {
return err
}
val, exists := doc.Find(".media__image").First().Attr("data-src")
if !exists {
return errors.New("we ran out of runny =(")
}
reply := &discordgo.MessageEmbed{
Title: ":rofl:",
Image: &discordgo.MessageEmbedImage{
URL: val,
},
Color: prettyembedcolor,
}
_, err = discord.ChannelMessageSendEmbed(msg.ChannelID, reply)
return err
}