internal static BotDatabase Load(string filePath)
{
if (string.IsNullOrEmpty(filePath)) {
ASF.ArchiLogger.LogNullError(nameof(filePath));
return null;
}
if (!File.Exists(filePath)) {
return new BotDatabase(filePath);
}
BotDatabase botDatabase;
try {
botDatabase = JsonConvert.DeserializeObject<BotDatabase>(File.ReadAllText(filePath));
} catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e);
return null;
}
if (botDatabase == null) {
ASF.ArchiLogger.LogNullError(nameof(botDatabase));
return null;
}
botDatabase.FilePath = filePath;
return botDatabase;
}