public async Task Connect() { if (File.Exists(Database[DatabaseType.Guild])) { Guilds = JsonConvert.DeserializeObject <ConfigGuilds>(File.ReadAllText(Database[DatabaseType.Guild])); } else { Guilds = new ConfigGuilds(); using (var stream = File.CreateText(Database[DatabaseType.Guild])) { await stream.WriteAsync(ConfigGuilds.Default); await stream.FlushAsync(); } } if (File.Exists(Database[DatabaseType.User])) { Users = JsonConvert.DeserializeObject <ConfigUsers>(File.ReadAllText(Database[DatabaseType.User])); } else { Users = new ConfigUsers(); using (var stream = File.CreateText(Database[DatabaseType.User])) { await stream.WriteAsync(ConfigUsers.Default); await stream.FlushAsync(); } } }
public Task Refresh() { Guilds = null; Users = null; return(Connect()); }