diff --git a/Geekbot.net/Commands/Help.cs b/Geekbot.net/Commands/Help.cs index 83374a8..1b3e285 100644 --- a/Geekbot.net/Commands/Help.cs +++ b/Geekbot.net/Commands/Help.cs @@ -29,7 +29,7 @@ namespace Geekbot.net.Commands sb.AppendLine("https://geekbot.pizzaandcoffee.rocks/commands"); var dm = await Context.User.GetOrCreateDMChannelAsync(); await dm.SendMessageAsync(sb.ToString()); - Context.Message.AddReactionAsync(new Emoji("✅")); + await Context.Message.AddReactionAsync(new Emoji("✅")); } catch (Exception e) { diff --git a/Geekbot.net/Commands/Wikipedia.cs b/Geekbot.net/Commands/Wikipedia.cs index d0ea945..e7b36cf 100644 --- a/Geekbot.net/Commands/Wikipedia.cs +++ b/Geekbot.net/Commands/Wikipedia.cs @@ -59,12 +59,12 @@ namespace Geekbot.net.Commands { Title = article.Title, Description = article.Extract, - ImageUrl = article.Thumbnail.Source.ToString(), + ImageUrl = article.Thumbnail?.Source.ToString(), Url = article.ContentUrls.Desktop.Page.ToString() }; await ReplyAsync("", false, eb.Build()); } - catch (HttpRequestException e) + catch (HttpRequestException) { await ReplyAsync("I couldn't find that article"); } @@ -79,6 +79,7 @@ namespace Geekbot.net.Commands var doc = new HtmlDocument(); doc.LoadHtml(extractHtml); var nodes = doc.DocumentNode.SelectNodes("//li"); + if (nodes == null) return "(List is to long to show)"; var sb = new StringBuilder(); foreach (var node in nodes) { diff --git a/Geekbot.net/Lib/ErrorHandler.cs b/Geekbot.net/Lib/ErrorHandler.cs index c0c3d95..dc67db2 100644 --- a/Geekbot.net/Lib/ErrorHandler.cs +++ b/Geekbot.net/Lib/ErrorHandler.cs @@ -47,7 +47,9 @@ namespace Geekbot.net.Lib { if (_errorsInChat) { - Context.Channel.SendMessageAsync($"{e.Message}\r\n```\r\n{e.InnerException}\r\n```"); + var resStackTrace = string.IsNullOrEmpty(e.InnerException?.ToString()) ? e.StackTrace : e.InnerException.ToString(); + var maxLen = Math.Min(resStackTrace.Length, 1850); + Context.Channel.SendMessageAsync($"{e.Message}\r\n```\r\n{resStackTrace?.Substring(0, maxLen)}\r\n```"); } else { @@ -72,6 +74,7 @@ namespace Geekbot.net.Lib } catch (Exception ex) { + Context.Channel.SendMessageAsync("Something went really really wrong here"); _logger.Error("Geekbot", "Errorception", ex); } } diff --git a/WikipediaApi/Page/PagePreview.cs b/WikipediaApi/Page/PagePreview.cs index 41ab6f3..c1de2d7 100644 --- a/WikipediaApi/Page/PagePreview.cs +++ b/WikipediaApi/Page/PagePreview.cs @@ -9,7 +9,7 @@ namespace WikipediaApi.Page { [JsonProperty("type")] [JsonConverter(typeof(StringEnumConverter))] - public PageTypes Type { get; set; } = PageTypes.NoExtract; + public PageTypes Type { get; set; } [JsonProperty("title")] public string Title { get; set; }