From c6bab91c4000e6f30f8e16e81a46cbdf710691b7 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 8 Nov 2016 22:05:04 +0100 Subject: [PATCH] Error message when mashape isn't specified --- src/NadekoBot/Modules/Searches/Searches.cs | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 9a370f80..38d398ed 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -206,9 +206,16 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var arg = name; if (string.IsNullOrWhiteSpace(arg)) { - await channel.SendMessageAsync("💢 Please enter a card name to search for.").ConfigureAwait(false); + await channel.SendMessageAsync("💢 `Please enter a card name to search for.`").ConfigureAwait(false); return; } + + if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.MashapeKey)) + { + await channel.SendMessageAsync("💢 `Bot owner didn't specify MashapeApiKey. You can't use this functionality.`").ConfigureAwait(false); + return; + } + await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); string response = ""; using (var http = new HttpClient()) @@ -256,10 +263,16 @@ $@"🌍 **Weather for** 【{obj["target"]}】 { var channel = (ITextChannel)umsg.Channel; + if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.MashapeKey)) + { + await channel.SendMessageAsync("💢 `Bot owner didn't specify MashapeApiKey. You can't use this functionality.`").ConfigureAwait(false); + return; + } + var arg = query; if (string.IsNullOrWhiteSpace(arg)) { - await channel.SendMessageAsync("💢 Please enter a search term.").ConfigureAwait(false); + await channel.SendMessageAsync("💢 `Please enter a search term.`").ConfigureAwait(false); return; } await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); @@ -293,9 +306,15 @@ $@"🌍 **Weather for** 【{obj["target"]}】 var arg = query; if (string.IsNullOrWhiteSpace(arg)) { - await channel.SendMessageAsync("💢 Please enter a search term.").ConfigureAwait(false); + await channel.SendMessageAsync("💢 `Please enter a search term.`").ConfigureAwait(false); return; } + if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.MashapeKey)) + { + await channel.SendMessageAsync("💢 `Bot owner didn't specify MashapeApiKey. You can't use this functionality.`").ConfigureAwait(false); + return; + } + await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); string res = ""; using (var http = new HttpClient())