Add swear command
parent
79f1fc62cb
commit
05adff76d0
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"github.com/bwmarrin/disgord/x/mux"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
//Generate a heckin swear word
|
||||
func getSwear(s *discordgo.Session, m *discordgo.Message, ctx *mux.Context) {
|
||||
resp := ""
|
||||
swear, err := http.Get("https://swear.jawa.moe/")
|
||||
if err != nil {
|
||||
resp = "Error fetching swear: " + err.Error()
|
||||
}
|
||||
defer swear.Body.Close()
|
||||
|
||||
if swear.StatusCode == http.StatusOK {
|
||||
body, err := ioutil.ReadAll(swear.Body)
|
||||
if err != nil {
|
||||
resp = "Error fetching swear: " + err.Error()
|
||||
}
|
||||
resp = string(body)
|
||||
}
|
||||
s.ChannelMessageSend(m.ChannelID, resp)
|
||||
}
|
|
@ -45,6 +45,7 @@ func main() {
|
|||
|
||||
// Register the build-in help command.
|
||||
Router.Route("help", "Display this message.", Router.Help)
|
||||
Router.Route("swear", "Make me swear!", getSwear)
|
||||
|
||||
//Open a connection to Discord
|
||||
err = Session.Open()
|
||||
|
|
Loading…
Reference in New Issue