Deal with MTG Gatherer downtime

This commit is contained in:
runebaas 2020-08-26 23:28:03 +02:00
parent 3c4a5c638b
commit 546b5450e7
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6

View file

@ -28,7 +28,7 @@ namespace Geekbot.Bot.Commands.Integrations
{ {
try try
{ {
var message = await Context.Channel.SendMessageAsync($":mag: Looking up\"{cardName}\", please wait..."); var message = await Context.Channel.SendMessageAsync($":mag: Looking up \"{cardName}\", please wait...");
var service = new CardService(); var service = new CardService();
var result = service var result = service
@ -36,7 +36,15 @@ namespace Geekbot.Bot.Commands.Integrations
// fewer cards less risk of deserialization problems, don't need more than one anyways... // fewer cards less risk of deserialization problems, don't need more than one anyways...
.Where(x => x.PageSize, 1); .Where(x => x.PageSize, 1);
var card = result.All().Value.FirstOrDefault(); var cards = await result.AllAsync();
if (!cards.IsSuccess)
{
await message.ModifyAsync(properties => properties.Content = $":warning: The Gatherer reacted in an unexpected way: {cards.Exception.Message}");
return;
}
var card = cards.Value.FirstOrDefault();
if (card == null) if (card == null)
{ {
await message.ModifyAsync(properties => properties.Content = ":red_circle: I couldn't find a card with that name..."); await message.ModifyAsync(properties => properties.Content = ":red_circle: I couldn't find a card with that name...");