Add swear command

pull/20/head
pocketjawa 2019-08-05 20:49:23 -04:00
parent 79f1fc62cb
commit 05adff76d0
2 changed files with 28 additions and 0 deletions

27
commands.go Normal file
View File

@ -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)
}

View File

@ -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()