private static IDictionary <int, DiscordWebhookData> FromJsonFile(string filePath) { var jsonData = File.ReadAllText(filePath); _All = DiscordWebhookData.FromJsonString(jsonData); return(All); }
/// <summary> /// Loads all webhooks from a specified file. /// </summary> /// <param name="file">The file from which the webhooks are loaded from</param> /// <returns>A dictionary with all webhooks</returns> public static Dictionary <int, DiscordWebhookData> FromFile(string file) { Dictionary <int, DiscordWebhookData> allWebhooks = GetAllWebhooks(); if (allWebhooks.Count > 0) { allWebhooks.Clear(); } using (StreamReader reader = new StreamReader(file)) { string line = reader.ReadLine(); // skip the first line while ((line = reader.ReadLine()) != null) { allWebhooks.Add(allWebhooks.Count + 1, DiscordWebhookData.FromSavedFormat(line)); } } return(allWebhooks); }