Add bot restart/kill command

pull/20/head
pocketjawa 2019-08-06 21:45:09 -04:00
parent 202d852b1b
commit 636b5d4bb6
2 changed files with 17 additions and 0 deletions

View File

@ -5,7 +5,9 @@ import (
"github.com/bwmarrin/disgord/x/mux" "github.com/bwmarrin/disgord/x/mux"
"github.com/nishanths/go-xkcd" "github.com/nishanths/go-xkcd"
"io/ioutil" "io/ioutil"
"log"
"net/http" "net/http"
"os"
"regexp" "regexp"
"strconv" "strconv"
) )
@ -84,3 +86,17 @@ func getXKCD(s *discordgo.Session, m *discordgo.Message, ctx *mux.Context) {
resp = comic.ImageURL resp = comic.ImageURL
s.ChannelMessageSend(m.ChannelID, resp) s.ChannelMessageSend(m.ChannelID, resp)
} }
//Restart the bot
func restartBot(s *discordgo.Session, m *discordgo.Message, ctx *mux.Context) {
if !checkRole(s, m, ctx, os.Getenv("POCKETBOT_ADMIN_ROLE")) {
resp := "OwO you aren't my daddy..."
s.ChannelMessageSend(m.ChannelID, resp)
return
}
resp := "Goodnight ;-;"
s.ChannelMessageSend(m.ChannelID, resp)
Session.Close()
log.Println("brb dying at the request of ", m.Author.String())
os.Exit(0)
}

View File

@ -57,6 +57,7 @@ func main() {
Router.Route("monday", "It's Maki Monday my dudes!", makiMonday) Router.Route("monday", "It's Maki Monday my dudes!", makiMonday)
Router.Route("mixes", "Post the link to my fire mixtapes!", postMixes) Router.Route("mixes", "Post the link to my fire mixtapes!", postMixes)
Router.Route("xkcd", "Post a specific, random, or the latest XKCD comic", getXKCD) Router.Route("xkcd", "Post a specific, random, or the latest XKCD comic", getXKCD)
Router.Route("restart", "Restart the bot.", restartBot)
//Open a connection to Discord //Open a connection to Discord
err = Session.Open() err = Session.Open()