dev: v3 .catfact

This commit is contained in:
Kwoth
2024-07-28 10:10:19 +00:00
parent 17e5ff8b89
commit b5e2b6f483
2 changed files with 25 additions and 11 deletions

View File

@@ -399,10 +399,14 @@ public partial class Searches : NadekoModule<SearchesService>
[Cmd]
public async Task Catfact()
{
using var http = _httpFactory.CreateClient();
var response = await http.GetStringAsync("https://catfact.ninja/fact");
var maybeFact = await _service.GetCatFactAsync();
var fact = JObject.Parse(response)["fact"].ToString();
if (!maybeFact.TryPickT0(out var fact, out var error))
{
await HandleErrorAsync(error);
return;
}
await Response().Confirm("🐈" + GetText(strs.catfact), fact).SendAsync();
}