private static void SetupFiles() { // Check for the appropriate directories. foreach (string dir in DataFileNames.Folders) // Check through all the necessary directories { if (!Directory.Exists(dir)) // If the directory does not exist { Directory.CreateDirectory(dir); // Then create it } } // Special case for Excel files. // Only used for admin stuff atm AdminDataManager.InitExcel(); // Now for the files // This loop uses Reflection to iterate through all of the file paths and create any missing files // The settings.json file is the only one that needs a default template generated for it, and was handled above. // The passedFolders variable is so that it skips the folder array. bool passedFolders = false; string file; foreach (FieldInfo fieldInfo in typeof(DataFileNames).GetFields(BindingFlags.Static | BindingFlags.Public)) { if (!passedFolders) { passedFolders = true; continue; } file = fieldInfo.GetValue(null) as string; if (!File.Exists(file)) { Console.WriteLine($"Generated {file}"); File.CreateText(file).Close(); // This creates the file, then closes the unecessary stream writer } } AchievementManager.LoadNodeMap(); // RESET DATES LastDateNode dates = JsonConvert.DeserializeObject <LastDateNode>(FileManager.ReadFullFile(DataFileNames.LastDateFile)); if (dates == null) { dates = new LastDateNode(DateTime.UtcNow.LastSunday(), DateTime.UtcNow); dates.Save(); } BotUtils.LastDate = dates; }
public async Task StrikeLogAsync([Remainder] string args = "") { if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.MODERATOR)) { return; } if (File.Exists(AdminDataManager.StrikeLogPath)) { await Context.Channel.SendFileAsync(AdminDataManager.StrikeLogPath); } else { AdminDataManager.InitExcel(); await ReplyAsync(BotUtils.KamtroText("Stirke file was missing, so I made a new one.")); await Context.Channel.SendFileAsync(AdminDataManager.StrikeLogPath); } }