From 3d6d093e87d3ea5cdaecdcc013fb2b801ab41bd3 Mon Sep 17 00:00:00 2001 From: pocketjawa Date: Sun, 26 Apr 2020 04:45:16 -0400 Subject: [PATCH] Add setplaying command --- commands.go | 18 ++++++++++++++++++ pocketbot.go | 1 + 2 files changed, 19 insertions(+) diff --git a/commands.go b/commands.go index 4f2d1e6..3016e04 100644 --- a/commands.go +++ b/commands.go @@ -13,6 +13,7 @@ import ( "os" "regexp" "strconv" + "strings" ) //Check member roles @@ -145,3 +146,20 @@ func goToSleep(s *discordgo.Session, m *discordgo.Message, ctx *mux.Context) { } s.ChannelMessageSendEmbed(m.ChannelID, embed) } + +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..." + s.ChannelMessageSend(m.ChannelID, resp) + return + } + var resp string + if len(ctx.Fields) > 1 { + arg := strings.Join(ctx.Fields[1:], " ") + s.UpdateStatus(0, arg) + resp = "Now playing: " + arg + } else { + resp = "random" + } + s.ChannelMessageSend(m.ChannelID, resp) +} diff --git a/pocketbot.go b/pocketbot.go index 2669360..85a6159 100644 --- a/pocketbot.go +++ b/pocketbot.go @@ -68,6 +68,7 @@ func main() { Router.Route("restart", "Restart the bot.", restartBot) Router.Route("kill", "Restart the bot.", restartBot) Router.Route("sleep", "Something about sleeping...", goToSleep) + Router.Route("setplaying", "Set the nowplaying message for the bot.", setNowPlaying) //Open a connection to Discord err = Session.Open()