diff --git a/NadekoBot/Classes/Music/StreamRequest.cs b/NadekoBot/Classes/Music/StreamRequest.cs index 870f3fa1..109e9219 100644 --- a/NadekoBot/Classes/Music/StreamRequest.cs +++ b/NadekoBot/Classes/Music/StreamRequest.cs @@ -57,6 +57,8 @@ namespace NadekoBot.Classes.Music { private void ResolveStreamLink() { VideoInfo video = null; try { + if (OnResolving != null) + OnResolving(); Console.WriteLine("Resolving video link"); video = DownloadUrlResolver.GetDownloadUrls(Searches.FindYoutubeUrlByKeywords(Query)) .Where(v => v.AdaptiveType == AdaptiveType.Audio) @@ -68,6 +70,8 @@ namespace NadekoBot.Classes.Music { Title = video.Title.Substring(0,video.Title.Length-10); // removing trailing "- You Tube" } catch (Exception ex) { privateState = StreamState.Completed; + if (OnResolvingFailed != null) + OnResolvingFailed(ex.Message); Console.WriteLine($"Failed resolving the link.{ex.Message}"); return; } @@ -83,6 +87,8 @@ namespace NadekoBot.Classes.Music { public Action OnBuffering = null; public Action OnStarted = null; public Action OnCompleted = null; + public Action OnResolving = null; + public Action OnResolvingFailed = null; //todo maybe add remove, in order to create remove at position command @@ -237,21 +243,19 @@ namespace NadekoBot.Classes.Music { Console.WriteLine($"Prebuffering finished in {bufferAttempts*500}"); } // prebuffering wait stuff end - - //Task.Run(async () => { while (true) { Console.WriteLine($"Title: {parent.Title} State:{State}"); await Task.Delay(200); } }); - if (parent.OnStarted != null) - parent.OnStarted(); - + if (buffer.Length > 0) { Console.WriteLine("Prebuffering complete."); } else { Console.WriteLine("Didn't buffer jack shit."); } - //for now wait for 3 seconds before starting playback. int blockSize = 1920 * NadekoBot.client.Audio().Config.Channels; byte[] voiceBuffer = new byte[blockSize]; + if (parent.OnStarted != null) + parent.OnStarted(); + int attempt = 0; while (!IsCanceled) { int readCount = 0; diff --git a/NadekoBot/Classes/NadekoStats.cs b/NadekoBot/Classes/NadekoStats.cs index 54302487..cc035cd0 100644 --- a/NadekoBot/Classes/NadekoStats.cs +++ b/NadekoBot/Classes/NadekoStats.cs @@ -47,18 +47,18 @@ namespace NadekoBot public void LoadStats() { _statsCache = - "Author: Kwoth" + - $"\nDiscord.Net version: {DiscordConfig.LibVersion}" + - $"\nRuntime: {_client.GetRuntime()}" + - $"\nBot Version: {BotVersion}" + - $"\nLogged in as: {_client.CurrentUser.Name}" + - $"\nBot id: {_client.CurrentUser.Id}" + - $"\nUptime: {GetUptimeString()}" + - $"\nServers: {_client.Servers.Count()}" + - $"\nChannels: {_client.Servers.Sum(s => s.AllChannels.Count())}" + - $"\nUsers: {_client.Servers.SelectMany(x => x.Users.Select(y => y.Id)).Count()} (non-unique)" + - $"\nHeap: {Math.Round(GC.GetTotalMemory(true) / (1024.0 * 1024.0), 2).ToString()}MB" + - $"\nCommands Ran this session: {_commandsRan}"; + "`Author: Kwoth`" + + //$"\nDiscord.Net version: {DiscordConfig.LibVersion}" + + //$"\nRuntime: {_client.GetRuntime()}" + + $"\n`Bot Version: {BotVersion}`" + + //$"\nLogged in as: {_client.CurrentUser.Name}" + + $"\n`Bot id: {_client.CurrentUser.Id}`" + + $"\n`Uptime: {GetUptimeString()}`" + + $"\n`Servers: {_client.Servers.Count()}`" + + $"\n`Channels: {_client.Servers.Sum(s => s.AllChannels.Count())}`" + + //$"\nUsers: {_client.Servers.SelectMany(x => x.Users.Select(y => y.Id)).Count()} (non-unique)" + + //$"\nHeap: {Math.Round(GC.GetTotalMemory(true) / (1024.0 * 1024.0), 2).ToString()}MB" + + $"\n`Commands Ran this session: {_commandsRan}`"; } public string GetStats() { diff --git a/NadekoBot/Modules/Administration.cs b/NadekoBot/Modules/Administration.cs index 3c37da12..2caa1677 100644 --- a/NadekoBot/Modules/Administration.cs +++ b/NadekoBot/Modules/Administration.cs @@ -272,7 +272,7 @@ namespace NadekoBot.Modules { .Description("Shows some basic stats for nadeko") .Do(async e => { var t = Task.Run(() => { - return "```" + NadekoStats.Instance.GetStats() + "\n" + Music.GetMusicStats() + "```"; + return NadekoStats.Instance.GetStats() + "\n`" + Music.GetMusicStats() + "`"; }); await e.Send(await t); diff --git a/NadekoBot/Modules/Music.cs b/NadekoBot/Modules/Music.cs index 944e6c08..7628af7a 100644 --- a/NadekoBot/Modules/Music.cs +++ b/NadekoBot/Modules/Music.cs @@ -84,6 +84,8 @@ namespace NadekoBot.Modules { await e.Send("Failed to create a music player for this server"); return; } + if (e.GetArg("query") == null || e.GetArg("query").Length < 5) + return; var player = musicPlayers[e.Server]; @@ -97,8 +99,14 @@ namespace NadekoBot.Modules { throw new NullReferenceException("StreamRequest is null."); Message msg = null; Message qmsg = null; + sr.OnResolving += async () => { + qmsg = await e.Send($":musical_note: **Resolving**... \"{e.GetArg("query")}\""); + }; + sr.OnResolvingFailed += async (err) => { + qmsg = await e.Send($":anger: :musical_note: **Resolving failed** for `{e.GetArg("query")}`"); + }; sr.OnQueued += async () => { - qmsg = await e.Send($":musical_note:**Queued** {sr.Title.TrimTo(55)}"); + await qmsg.Edit($":musical_note:**Queued** {sr.Title.TrimTo(55)}"); }; sr.OnCompleted += async () => { await e.Send($":musical_note:**Finished playing** {sr.Title.TrimTo(55)}");