Bug fixes in !wiki and errorHandler
This commit is contained in:
parent
4548c6083a
commit
f5fd9ba017
4 changed files with 9 additions and 5 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Reference in a new issue