Merge branch 'dev' of pocketjawa/discord-pocketbot-go into master
commit
c649e11949
18
commands.go
18
commands.go
|
@ -147,6 +147,7 @@ func goToSleep(s *discordgo.Session, m *discordgo.Message, ctx *mux.Context) {
|
|||
s.ChannelMessageSendEmbed(m.ChannelID, embed)
|
||||
}
|
||||
|
||||
//Set now playing status
|
||||
func setNowPlaying(s *discordgo.Session, m *discordgo.Message, ctx *mux.Context) {
|
||||
if !checkRole(s, m, ctx, bot_admin_role) {
|
||||
resp := "OwO you aren't my daddy..."
|
||||
|
@ -158,6 +159,23 @@ func setNowPlaying(s *discordgo.Session, m *discordgo.Message, ctx *mux.Context)
|
|||
arg := strings.Join(ctx.Fields[1:], " ")
|
||||
s.UpdateStatus(0, arg)
|
||||
resp = "Now playing: " + arg
|
||||
f, err := os.Create("userdata/nowplaying.txt")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
_, err = f.WriteString(arg)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
f.Close()
|
||||
return
|
||||
}
|
||||
log.Println("Updated Now Playing to", arg, "at the request of", m.Author.String())
|
||||
err = f.Close()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
resp = "Please tell me what to play!"
|
||||
}
|
||||
|
|
12
pocketbot.go
12
pocketbot.go
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"github.com/bwmarrin/disgord/x/mux"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
"os"
|
||||
|
@ -89,7 +90,16 @@ func main() {
|
|||
}
|
||||
|
||||
func ready(s *discordgo.Session, event *discordgo.Ready) {
|
||||
s.UpdateStatus(0, "with droids!")
|
||||
playingstatus := "with droids!"
|
||||
_, err := os.Stat("userdata/nowplaying.txt")
|
||||
if !os.IsNotExist(err) {
|
||||
content, err := ioutil.ReadFile("userdata/nowplaying.txt")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
playingstatus = string(content)
|
||||
}
|
||||
s.UpdateStatus(0, playingstatus)
|
||||
if os.Getenv("POCKETBOT_STARTUP_MESSAGE") == "TRUE" {
|
||||
s.ChannelMessageSend(bot_channel, "This isn't Tatooine...")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue