diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 6c98212c6..cae1fda29 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -135,10 +135,15 @@ namespace ArchiSteamFarm { throw new ArgumentNullException(nameof(botName)); } - BotName = botName; + if (Bots.ContainsKey(botName)) { + throw new Exception("That bot is already defined!"); + } string botPath = Path.Combine(Program.ConfigDirectory, botName); + BotName = botName; + SentryFile = botPath + ".bin"; + BotConfig = BotConfig.Load(botPath + ".json"); if (BotConfig == null) { Logging.LogGenericError("Your bot config is invalid, refusing to start this bot instance!", botName); @@ -150,14 +155,6 @@ namespace ArchiSteamFarm { return; } - if (Bots.ContainsKey(botName)) { - throw new Exception("That bot is already defined!"); - } - - Bots[botName] = this; - - SentryFile = botPath + ".bin"; - BotDatabase = BotDatabase.Load(botPath + ".db"); if (BotDatabase == null) { Logging.LogGenericError("Bot database could not be loaded, refusing to start this bot instance!", botName); @@ -248,6 +245,9 @@ namespace ArchiSteamFarm { ); } + // Register bot as available for ASF + Bots[botName] = this; + if (!BotConfig.StartOnLaunch) { return; } @@ -993,6 +993,7 @@ namespace ArchiSteamFarm { if (Bots.TryGetValue(botName, out bot)) { return await bot.ResponseRedeem(steamID, message, validate).ConfigureAwait(false); } + if (IsOwner(steamID)) { return "Couldn't find any bot named " + botName + "!"; }