From be4b4e06def47d2f5a52b9b85af72cc0e8f37982 Mon Sep 17 00:00:00 2001 From: pocketjawa Date: Sun, 26 Apr 2020 02:57:21 -0400 Subject: [PATCH] Move bot admin role to be a global variable. --- commands.go | 2 +- pocketbot.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/commands.go b/commands.go index b45585a..dab7bcb 100644 --- a/commands.go +++ b/commands.go @@ -122,7 +122,7 @@ func getXKCD(s *discordgo.Session, m *discordgo.Message, ctx *mux.Context) { //Restart the bot func restartBot(s *discordgo.Session, m *discordgo.Message, ctx *mux.Context) { - if !checkRole(s, m, ctx, os.Getenv("POCKETBOT_ADMIN_ROLE")) { + if !checkRole(s, m, ctx, bot_admin_role) { resp := "OwO you aren't my daddy..." s.ChannelMessageSend(m.ChannelID, resp) return diff --git a/pocketbot.go b/pocketbot.go index 2ff2df9..df0a091 100644 --- a/pocketbot.go +++ b/pocketbot.go @@ -16,6 +16,7 @@ import ( var Session, _ = discordgo.New() var bot_token string var bot_channel string +var bot_admin_role string var Router = mux.New() func init() { @@ -31,6 +32,9 @@ func init() { if os.Getenv("DISCORD_BOT_CHANNEL") != "" { bot_channel = os.Getenv("DISCORD_BOT_CHANNEL") } + if os.Getenv("POCKETBOT_ADMIN_ROLE") != "" { + bot_admin_role = os.Getenv("POCKETBOT_ADMIN_ROLE") + } } func main() {