From ec9dd33a021ab5451617818404303324afe914b3 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Sat, 6 Feb 2016 18:16:49 +0100 Subject: [PATCH] fixys --- NadekoBot/Classes/Music/MusicControls.cs | 2 +- NadekoBot/Modules/Searches.cs | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/NadekoBot/Classes/Music/MusicControls.cs b/NadekoBot/Classes/Music/MusicControls.cs index 31d64ca1..de33436a 100644 --- a/NadekoBot/Classes/Music/MusicControls.cs +++ b/NadekoBot/Classes/Music/MusicControls.cs @@ -68,7 +68,7 @@ namespace NadekoBot.Classes.Music { VoiceClient = await NadekoBot.client.Audio().Join(VoiceChannel); Console.WriteLine($"Joined voicechannel [{DateTime.Now.Second}]"); } - await Task.Factory.StartNew(async () => await CurrentSong.Start(), TaskCreationOptions.LongRunning).Unwrap(); + await Task.Factory.StartNew(async () => await CurrentSong?.Start(), TaskCreationOptions.LongRunning).Unwrap(); } catch (Exception ex) { Console.WriteLine($"Starting failed: {ex}"); CurrentSong?.Stop(); diff --git a/NadekoBot/Modules/Searches.cs b/NadekoBot/Modules/Searches.cs index 1953d138..1e8bc79d 100644 --- a/NadekoBot/Modules/Searches.cs +++ b/NadekoBot/Modules/Searches.cs @@ -208,21 +208,25 @@ namespace NadekoBot.Modules { cgb.CreateCommand("~osu") .Description("Shows osu stats for a player\n**Usage**:~osu Name") - .Parameter("usr",ParameterType.Unparsed) + .Parameter("usr", ParameterType.Unparsed) .Do(async e => { if (string.IsNullOrWhiteSpace(e.GetArg("usr"))) return; - try { - using (WebClient cl = new WebClient()) { + + using (WebClient cl = new WebClient()) { + try { cl.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore); cl.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 6.2; Win64; x64)"); cl.DownloadDataAsync(new Uri($"http://lemmmy.pw/osusig/sig.php?uname={ e.GetArg("usr") }&flagshadow&xpbar&xpbarhex&pp=2")); cl.DownloadDataCompleted += async (s, cle) => { - await e.Channel.SendFile($"{e.GetArg("usr")}.png", new MemoryStream(cle.Result)); + try { + await e.Channel.SendFile($"{e.GetArg("usr")}.png", new MemoryStream(cle.Result)); + await e.Send($"`Profile Link:`https://osu.ppy.sh/u/{Uri.EscapeDataString(e.GetArg("usr"))}\n`Image provided by https://lemmmy.pw/osusig`"); + } catch (Exception) { } }; + } catch (Exception ex) { + await e.Channel.SendMessage(":anger: Failed retrieving osu signature :\\"); } - } catch (Exception ex) { - await e.Channel.SendMessage(":anger: " + ex.Message); } });