예제 #1
0
 public void SaveSharedInfo()
 {
     CVTS.WriteLineShared($"Attempting to save shared info for discord guild ID {DiscordGuildId}...");
     if (!Directory.Exists(SharedInfoLocation))
     {
         CVTS.WriteLineShared($"Shared info directory not found! directory will now be created...");
         Directory.CreateDirectory(SharedInfoLocation);
     }
     try
     {
         File.WriteAllText(@$ "{SharedInfoLocation}\{DiscordGuildId}.json", JsonConvert.SerializeObject(this));
         CVTS.WriteLineOk($"Saved shared info successfully.");
     }
예제 #2
0
 public static void LoadSharedInfo()
 {
     CVTS.WriteLineShared($"Loading shared info from '{SharedInfoLocation}'...");
     if (!Directory.Exists(SharedInfoLocation))
     {
         CVTS.WriteLineShared($"Shared info directory not found! directory will now be created...");
         Directory.CreateDirectory(SharedInfoLocation);
     }
     else
     {
         foreach (string file in Directory.EnumerateFiles(SharedInfoLocation, "*.json", SearchOption.TopDirectoryOnly))
         {
             SharedBotInfo b = JsonConvert.DeserializeObject <SharedBotInfo>(File.ReadAllText(file));
             sharedInfoCollection.Add(b);
         }
     }
     CVTS.WriteLineOk($"Successfully loaded shared info for {sharedInfoCollection.Count} servers!");
 }