From 49ce944d30cbff7124ccfa5b2ba0dde81478935c Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 26 Aug 2021 00:31:20 +0200 Subject: [PATCH] Fix: Prevent activating duplicate module ID Signed-off-by: Knut Ahlers --- main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.go b/main.go index 08e808a..b40903b 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( log "github.com/sirupsen/logrus" httpHelpers "github.com/Luzifer/go_helpers/v2/http" + "github.com/Luzifer/go_helpers/v2/str" "github.com/Luzifer/rconfig/v2" ) @@ -73,6 +74,7 @@ func main() { discord.Identify.Intents = discordgo.IntentsAll + var activeIDs []string for i, mc := range config.ModuleConfigs { logger := log.WithFields(log.Fields{ "id": mc.ID, @@ -80,6 +82,11 @@ func main() { "module": mc.Type, }) + if str.StringInSlice(mc.ID, activeIDs) { + logger.Error("Found duplicate module ID, module will be disabled") + continue + } + if mc.ID == "" { logger.Error("Module contains no ID and will be disabled") continue @@ -95,6 +102,7 @@ func main() { } activeModules = append(activeModules, mod) + activeIDs = append(activeIDs, mc.ID) logger.Debug("Enabled module") }