From 276e9bfe8e19a6b5bb4adc4f48e0e2bfeba2bd29 Mon Sep 17 00:00:00 2001 From: runebaas Date: Tue, 1 May 2018 00:19:03 +0200 Subject: [PATCH] add null checking in !urban --- Geekbot.net/Commands/UrbanDictionary.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Geekbot.net/Commands/UrbanDictionary.cs b/Geekbot.net/Commands/UrbanDictionary.cs index a951cb8..2af43ba 100644 --- a/Geekbot.net/Commands/UrbanDictionary.cs +++ b/Geekbot.net/Commands/UrbanDictionary.cs @@ -49,10 +49,10 @@ namespace Geekbot.net.Commands Url = definition.Permalink }); eb.WithColor(new Color(239, 255, 0)); - eb.Description = definition.Definition; - eb.AddField("Example", definition.Example ?? "(no example given...)"); - eb.AddInlineField("Upvotes", definition.ThumbsUp); - eb.AddInlineField("Downvotes", definition.ThumbsDown); + if (!string.IsNullOrEmpty(definition.Definition)) eb.Description = definition.Definition; + if (!string.IsNullOrEmpty(definition.Example)) eb.AddField("Example", definition.Example ?? "(no example given...)"); + if (!string.IsNullOrEmpty(definition.ThumbsUp)) eb.AddInlineField("Upvotes", definition.ThumbsUp); + if (!string.IsNullOrEmpty(definition.ThumbsDown)) eb.AddInlineField("Downvotes", definition.ThumbsDown); if (definitions.Tags.Length > 0) eb.AddField("Tags", string.Join(", ", definitions.Tags)); await ReplyAsync("", false, eb.Build());