Use the new Csharp 8 features (pattern matching and using assignments) and cleanup some insignificant resparper complaints

This commit is contained in:
runebaas 2020-02-08 15:58:17 +01:00
parent 21f813d342
commit 3568b61f38
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
27 changed files with 217 additions and 250 deletions

View file

@ -23,24 +23,27 @@ namespace Geekbot.net.Commands.Randomness.Cat
{
try
{
using (var client = new HttpClient())
try
{
try
using var client = new HttpClient
{
client.BaseAddress = new Uri("https://aws.random.cat");
var response = await client.GetAsync("/meow");
response.EnsureSuccessStatusCode();
BaseAddress = new Uri("https://aws.random.cat")
};
var response = await client.GetAsync("/meow");
response.EnsureSuccessStatusCode();
var stringResponse = await response.Content.ReadAsStringAsync();
var catFile = JsonConvert.DeserializeObject<CatResponseDto>(stringResponse);
var eb = new EmbedBuilder();
eb.ImageUrl = catFile.File;
await ReplyAsync("", false, eb.Build());
}
catch
var stringResponse = await response.Content.ReadAsStringAsync();
var catFile = JsonConvert.DeserializeObject<CatResponseDto>(stringResponse);
var eb = new EmbedBuilder
{
await ReplyAsync("Seems like the dog cought the cat (error occured)");
}
ImageUrl = catFile.File
};
await ReplyAsync("", false, eb.Build());
}
catch
{
await ReplyAsync("Seems like the dog cought the cat (error occured)");
}
}
catch (Exception e)