From 9256c019dea176bf0c94cc09e2b0efeb8f91cd17 Mon Sep 17 00:00:00 2001 From: TechnoStrife Date: Thu, 10 Oct 2024 12:00:16 +0300 Subject: [PATCH] Add server install command --- commands/admin/mod.go | 6 +++--- commands/admin/server.go | 25 ++++++++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/commands/admin/mod.go b/commands/admin/mod.go index b56d5dd..7511a99 100644 --- a/commands/admin/mod.go +++ b/commands/admin/mod.go @@ -287,7 +287,7 @@ func modsAdd(s *discordgo.Session, mods *ModJSON, modDescriptions *[]modDescript alreadyAdded := support.DefaultTextList("\n**Already added:**") userErrors := support.DefaultTextList("\n**Errors:**") - factorioVersion, err := factorioVersion() + factorioVersion, err := getFactorioVersionNoPatch() if err != nil { return "Error checking factorio version" } @@ -350,7 +350,7 @@ func modsAdd(s *discordgo.Session, mods *ModJSON, modDescriptions *[]modDescript return res } -func factorioVersion() (string, error) { +func getFactorioVersionNoPatch() (string, error) { factorioVersion, err := support.FactorioVersion() if err != nil { return "", err @@ -374,7 +374,7 @@ func modsUpdate(s *discordgo.Session, mods *ModJSON, modDescriptions *[]modDescr files := matchModsWithFiles(&mods.Mods) - factorioVersion, err := factorioVersion() + factorioVersion, err := getFactorioVersionNoPatch() if err != nil { return "Error checking factorio version" } diff --git a/commands/admin/server.go b/commands/admin/server.go index ce22eec..f3ad595 100644 --- a/commands/admin/server.go +++ b/commands/admin/server.go @@ -32,6 +32,12 @@ var ServerCommandDoc = support.CommandDoc{ Usage: "$server update\n" + "$server update ", }, + { + Name: "install", + Doc: `same as update, but does not check version of the factorio server`, + Usage: "$server install\n" + + "$server install ", + }, }, } @@ -55,24 +61,29 @@ func ServerCommand(s *discordgo.Session, args string) { case "restart": support.Factorio.Stop(s) support.Factorio.Start(s) + case "install": + serverUpdate(s, false, arg) case "update": - serverUpdate(s, arg) + serverUpdate(s, true, arg) default: support.SendFormat(s, "Usage: "+ServerCommandDoc.Usage) } } -func serverUpdate(s *discordgo.Session, version string) { +func serverUpdate(s *discordgo.Session, checkVersion bool, version string) { if support.Factorio.IsRunning() { support.Send(s, "You should stop the server first") return } + var factorioVersion string = "-1" var err error - factorioVersion, err := support.FactorioVersion() - if err != nil { - support.Panik(err, "... checking factorio version") - support.Send(s, "Error checking factorio version") - return + if checkVersion { + factorioVersion, err = support.FactorioVersion() + if err != nil { + support.Panik(err, "... checking factorio version") + support.Send(s, "Error checking factorio version") + return + } } if version == "" {