NRE fixes in simpleMessageConverter, !urban and errorHandler

This commit is contained in:
runebaas 2018-09-02 21:58:16 +02:00
parent 6a163366ea
commit 5a4e710ef9
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
3 changed files with 8 additions and 8 deletions

View file

@ -52,7 +52,7 @@ namespace Geekbot.net.Commands.Integrations.UbranDictionary
if (!string.IsNullOrEmpty(definition.Example)) eb.AddField("Example", definition.Example ?? "(no example given...)"); 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.ThumbsUp)) eb.AddInlineField("Upvotes", definition.ThumbsUp);
if (!string.IsNullOrEmpty(definition.ThumbsDown)) eb.AddInlineField("Downvotes", definition.ThumbsDown); if (!string.IsNullOrEmpty(definition.ThumbsDown)) eb.AddInlineField("Downvotes", definition.ThumbsDown);
if (definitions.Tags.Length > 0) eb.AddField("Tags", string.Join(", ", definitions.Tags)); if (definitions.Tags?.Length > 0) eb.AddField("Tags", string.Join(", ", definitions.Tags));
await ReplyAsync("", false, eb.Build()); await ReplyAsync("", false, eb.Build());
} }

View file

@ -39,7 +39,7 @@ namespace Geekbot.net.Lib.ErrorHandling
{ {
try try
{ {
var errorString = errorMessage == "def" ? await _translation.GetString(context.Guild.Id, "errorHandler", "SomethingWentWrong") : errorMessage; var errorString = errorMessage == "def" ? await _translation.GetString(context.Guild?.Id ?? 0, "errorHandler", "SomethingWentWrong") : errorMessage;
var errorObj = SimpleConextConverter.ConvertContext(context); var errorObj = SimpleConextConverter.ConvertContext(context);
if (e.Message.Contains("50007")) return; if (e.Message.Contains("50007")) return;
if (e.Message.Contains("50013")) return; if (e.Message.Contains("50013")) return;

View file

@ -25,13 +25,13 @@ namespace Geekbot.net.Lib.Logger
}, },
Guild = new MessageDto.IdAndName Guild = new MessageDto.IdAndName
{ {
Id = context.Guild.Id.ToString(), Id = context.Guild?.Id.ToString(),
Name = context.Guild.Name Name = context.Guild?.Name
}, },
Channel = new MessageDto.IdAndName Channel = new MessageDto.IdAndName
{ {
Id = context.Channel.Id.ToString(), Id = context.Channel?.Id.ToString() ?? context.User.Id.ToString(),
Name = context.Channel.Name Name = context.Channel?.Name ?? "DM-Channel"
} }
}; };
} }
@ -61,8 +61,8 @@ namespace Geekbot.net.Lib.Logger
}, },
Channel = new MessageDto.IdAndName Channel = new MessageDto.IdAndName
{ {
Id = channel?.Id.ToString(), Id = channel?.Id.ToString() ?? message.Author.Id.ToString(),
Name = channel?.Name Name = channel?.Name ?? "DM-Channel"
} }
}; };
} }