discord-pocketbot-go/commands.go

34 lines
805 B
Go

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)
}
//Post the Maki Monday pic!
func makiMonday(s *discordgo.Session, m *discordgo.Message, ctx *mux.Context) {
resp := "https://maki.jawa.moe/monday.png"
s.ChannelMessageSend(m.ChannelID, resp)
}