public static DiscordServerChannelModel RemoveChannelFormat(DiscordServerChannelModel serverInformation, string formatName) { var listFormats = serverInformation.ListOfFormats ?? new List <string>(); if (listFormats.Contains(formatName)) { listFormats.Remove(formatName); } serverInformation.ListOfFormats = listFormats; return(UpdateServerInfo(serverInformation)); }
public static DiscordServerChannelModel UpdateServerInfo(DiscordServerChannelModel serverInformation) { string FilePath = Path.Combine(serverInfoLocation, $"{serverInformation.serverID}.json"); using (StreamWriter file = File.CreateText(FilePath)) { var serializer = new JsonSerializer { Formatting = Formatting.Indented }; serializer.Serialize(file, serverInformation); Console.WriteLine($"{serverInformation.serverID}.json updated successfully."); } UpdateListOfRegisteredGuilds(serverInformation); return(serverInformation); }
private static void UpdateListOfRegisteredGuilds(DiscordServerChannelModel serverInformation) { string FilePath = Path.Combine(serverInfoLocation, registeredServerNames); var currentServerInfo = ReadRegisteredDiscordGuilds(); if (currentServerInfo.ListOfRegisteredDiscordGuilds == null) { currentServerInfo.ListOfRegisteredDiscordGuilds = new List <ulong>(); } if (!currentServerInfo.ListOfRegisteredDiscordGuilds.Contains(serverInformation.serverID)) { currentServerInfo.ListOfRegisteredDiscordGuilds.Add(serverInformation.serverID); } using (StreamWriter file = File.CreateText(FilePath)) { var serializer = new JsonSerializer { Formatting = Formatting.Indented }; serializer.Serialize(file, currentServerInfo); } }