From 546b5450e7d10b325461bf7cfea1d750de5c2270 Mon Sep 17 00:00:00 2001 From: runebaas Date: Wed, 26 Aug 2020 23:28:03 +0200 Subject: [PATCH] Deal with MTG Gatherer downtime --- src/Bot/Commands/Integrations/MagicTheGathering.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Bot/Commands/Integrations/MagicTheGathering.cs b/src/Bot/Commands/Integrations/MagicTheGathering.cs index 66a87fe..b179d6e 100644 --- a/src/Bot/Commands/Integrations/MagicTheGathering.cs +++ b/src/Bot/Commands/Integrations/MagicTheGathering.cs @@ -28,7 +28,7 @@ namespace Geekbot.Bot.Commands.Integrations { 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 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... .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) { await message.ModifyAsync(properties => properties.Content = ":red_circle: I couldn't find a card with that name...");