mirror of
https://github.com/Luzifer/discord-community.git
synced 2024-12-20 10:21:22 +00:00
Fix: Prevent activating duplicate module ID
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
35888b0abd
commit
49ce944d30
1 changed files with 8 additions and 0 deletions
8
main.go
8
main.go
|
@ -11,6 +11,7 @@ import (
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
httpHelpers "github.com/Luzifer/go_helpers/v2/http"
|
httpHelpers "github.com/Luzifer/go_helpers/v2/http"
|
||||||
|
"github.com/Luzifer/go_helpers/v2/str"
|
||||||
"github.com/Luzifer/rconfig/v2"
|
"github.com/Luzifer/rconfig/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -73,6 +74,7 @@ func main() {
|
||||||
|
|
||||||
discord.Identify.Intents = discordgo.IntentsAll
|
discord.Identify.Intents = discordgo.IntentsAll
|
||||||
|
|
||||||
|
var activeIDs []string
|
||||||
for i, mc := range config.ModuleConfigs {
|
for i, mc := range config.ModuleConfigs {
|
||||||
logger := log.WithFields(log.Fields{
|
logger := log.WithFields(log.Fields{
|
||||||
"id": mc.ID,
|
"id": mc.ID,
|
||||||
|
@ -80,6 +82,11 @@ func main() {
|
||||||
"module": mc.Type,
|
"module": mc.Type,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if str.StringInSlice(mc.ID, activeIDs) {
|
||||||
|
logger.Error("Found duplicate module ID, module will be disabled")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if mc.ID == "" {
|
if mc.ID == "" {
|
||||||
logger.Error("Module contains no ID and will be disabled")
|
logger.Error("Module contains no ID and will be disabled")
|
||||||
continue
|
continue
|
||||||
|
@ -95,6 +102,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
activeModules = append(activeModules, mod)
|
activeModules = append(activeModules, mod)
|
||||||
|
activeIDs = append(activeIDs, mc.ID)
|
||||||
|
|
||||||
logger.Debug("Enabled module")
|
logger.Debug("Enabled module")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue