forked from EllieBotDevs/elliebot
v3 .catfact
This commit is contained in:
parent
586f5ba4b0
commit
3a597a49ea
2 changed files with 24 additions and 11 deletions
src/EllieBot/Modules/Searches
|
@ -399,10 +399,14 @@ public partial class Searches : EllieModule<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();
|
||||
|
||||
if (!maybeFact.TryPickT0(out var fact, out var error))
|
||||
{
|
||||
await HandleErrorAsync(error);
|
||||
return;
|
||||
}
|
||||
|
||||
var fact = JObject.Parse(response)["fact"].ToString();
|
||||
await Response().Confirm("🐈" + GetText(strs.catfact), fact).SendAsync();
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue