From fcbbeccaa80c7e120933682b330272a1490c1cf5 Mon Sep 17 00:00:00 2001 From: hachem Date: Sat, 29 Aug 2026 18:24:42 +0200 Subject: refactor: unify mods command with the search --- internal/bot/bot.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'internal/bot/bot.go') diff --git a/internal/bot/bot.go b/internal/bot/bot.go index 48e395b..39fd00b 100644 --- a/internal/bot/bot.go +++ b/internal/bot/bot.go @@ -114,17 +114,21 @@ func checkMods(cfg *config.Config, client *modrinth.Client) report { newCache := config.Cache{} var rep report - for _, slug := range cfg.ModrinthMods { - versions, err := client.GetVersions(slug) + for _, mod := range cfg.ModrinthMods { + if mod.Pinned() { + continue + } + + versions, err := client.GetVersions(mod.Slug) if err != nil { - log.Printf("[Modrinth] failed for %s: %v", slug, err) + log.Printf("[Modrinth] failed for %s: %v", mod.Slug, err) continue } latest := modrinth.LatestVersion(versions) compatible := modrinth.CompatibleVersion(versions, cfg.MinecraftVersion, "") - cached := cache[slug] + cached := cache[mod.Slug] state := config.ModState{} if compatible != nil { @@ -133,15 +137,15 @@ func checkMods(cfg *config.Config, client *modrinth.Client) report { if latest != nil { state.Latest = latest.ID } - newCache[slug] = state + newCache[mod.Slug] = state switch { case compatible == nil: - rep.noCompatible = append(rep.noCompatible, slug) + rep.noCompatible = append(rep.noCompatible, mod.Slug) case cached.Compatible == "": - rep.newlyCompatible = append(rep.newlyCompatible, slug) + rep.newlyCompatible = append(rep.newlyCompatible, mod.Slug) case latest != nil && latest.ID != cached.Latest: - rep.stillCompatibleUpdate = append(rep.stillCompatibleUpdate, slug) + rep.stillCompatibleUpdate = append(rep.stillCompatibleUpdate, mod.Slug) } } -- cgit v1.3