From 4e7b7a6ee5ef2b5009d2ce7590c92ed545e98a55 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Thu, 15 Jun 2017 20:04:15 +0200 Subject: [PATCH] invalid hex error --- src/NadekoBot/Modules/Searches/Searches.cs | 14 +++++++++++++- .../Services/Administration/VplusTService.cs | 17 ++++++----------- .../_strings/ResponseStrings.en-US.json | 1 + 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 8e1b2a2c..b7886f44 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -637,9 +637,21 @@ namespace NadekoBot.Modules.Searches color = color?.Trim().Replace("#", ""); if (string.IsNullOrWhiteSpace(color)) return; + ImageSharp.Color clr; + try + { + clr = ImageSharp.Color.FromHex(color); + } + catch + { + await ReplyErrorLocalized("hex_invalid").ConfigureAwait(false); + return; + } + + var img = new ImageSharp.Image(50, 50); - img.BackgroundColor(ImageSharp.Color.FromHex(color)); + img.BackgroundColor(clr); await Context.Channel.SendFileAsync(img.ToStream(), $"{color}.png").ConfigureAwait(false); } diff --git a/src/NadekoBot/Services/Administration/VplusTService.cs b/src/NadekoBot/Services/Administration/VplusTService.cs index 469aab02..3d9e86cd 100644 --- a/src/NadekoBot/Services/Administration/VplusTService.cs +++ b/src/NadekoBot/Services/Administration/VplusTService.cs @@ -93,16 +93,11 @@ namespace NadekoBot.Services.Administration var beforeRoleName = GetRoleName(beforeVch); var beforeRole = guild.Roles.FirstOrDefault(x => x.Name == beforeRoleName); if (beforeRole != null) - try - { - _log.Info("Removing role " + beforeRoleName + " from user " + user.Username); - await user.RemoveRoleAsync(beforeRole).ConfigureAwait(false); - await Task.Delay(200).ConfigureAwait(false); - } - catch (Exception ex) - { - _log.Warn(ex); - } + { + _log.Info("Removing role " + beforeRoleName + " from user " + user.Username); + await user.RemoveRoleAsync(beforeRole).ConfigureAwait(false); + await Task.Delay(200).ConfigureAwait(false); + } } var afterVch = after.VoiceChannel; if (afterVch != null && guild.AFKChannel?.Id != afterVch.Id) @@ -130,7 +125,7 @@ namespace NadekoBot.Services.Administration .ConfigureAwait(false); await Task.Delay(50).ConfigureAwait(false); } - _log.Warn("Adding role " + roleToAdd.Name + " to user " + user.Username); + _log.Info("Adding role " + roleToAdd.Name + " to user " + user.Username); await user.AddRoleAsync(roleToAdd).ConfigureAwait(false); } } diff --git a/src/NadekoBot/_strings/ResponseStrings.en-US.json b/src/NadekoBot/_strings/ResponseStrings.en-US.json index cca1c577..2aef3353 100644 --- a/src/NadekoBot/_strings/ResponseStrings.en-US.json +++ b/src/NadekoBot/_strings/ResponseStrings.en-US.json @@ -534,6 +534,7 @@ "searches_hashtag_error": "Failed finding a definition for that tag.", "searches_height_weight": "Height/Weight", "searches_height_weight_val": "{0}m/{1}kg", + "searches_hex_invalid": "Invalid color specified.", "searches_humidity": "Humidity", "searches_image_search_for": "Image search for:", "searches_imdb_fail": "Failed to find that movie.",