From 638ddbd3b174c2af2463350b67c8a9e7a394b491 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Mon, 7 Mar 2016 09:17:15 +0100 Subject: [PATCH] fixed permissions, depercated !M setgame, debugging stuff --- NadekoBot/Classes/Music/Song.cs | 14 +++++++++++++- .../Classes/Permissions/PermissionsHandler.cs | 2 +- NadekoBot/Commands/LoLCommands.cs | 4 +++- NadekoBot/Modules/Music.cs | 12 ++++-------- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/NadekoBot/Classes/Music/Song.cs b/NadekoBot/Classes/Music/Song.cs index e15db946..2366f0ed 100644 --- a/NadekoBot/Classes/Music/Song.cs +++ b/NadekoBot/Classes/Music/Song.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics; using System.IO; using System.Linq; +using System.Runtime.CompilerServices; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; @@ -180,7 +181,16 @@ namespace NadekoBot.Classes.Music { }); internal async Task Play(IAudioClient voiceClient, CancellationToken cancelToken) { - var bufferTask = BufferSong(cancelToken).ConfigureAwait(false); + var bufferTask = new ConfiguredTaskAwaitable(); + try { + bufferTask = BufferSong(cancelToken).ConfigureAwait(false); + } + catch (Exception ex) { + var clr = Console.ForegroundColor; + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine($"ERR BUFFER START : {ex.Message}\n{ex}"); + Console.ForegroundColor = clr; + } var bufferAttempts = 0; const int waitPerAttempt = 500; var toAttemptTimes = SongInfo.ProviderType != MusicType.Normal ? 5 : 9; @@ -197,8 +207,10 @@ namespace NadekoBot.Classes.Music { var read = songBuffer.Read(buffer, blockSize); if (read == 0) if (attempt++ == 20) { + Console.WriteLine("Waiting to empty out buffer."); voiceClient.Wait(); await bufferTask; + Console.WriteLine("Song finished."); return; } else diff --git a/NadekoBot/Classes/Permissions/PermissionsHandler.cs b/NadekoBot/Classes/Permissions/PermissionsHandler.cs index d360c378..04afac85 100644 --- a/NadekoBot/Classes/Permissions/PermissionsHandler.cs +++ b/NadekoBot/Classes/Permissions/PermissionsHandler.cs @@ -140,7 +140,7 @@ namespace NadekoBot.Classes.Permissions { } private static void WriteServerToJson(ServerPermissions serverPerms) { - string pathToFile = $"data/permissions/{serverPerms}.json"; + string pathToFile = $"data/permissions/{serverPerms.Id}.json"; File.WriteAllText(pathToFile, Newtonsoft.Json.JsonConvert.SerializeObject(serverPerms, Newtonsoft.Json.Formatting.Indented)); } diff --git a/NadekoBot/Commands/LoLCommands.cs b/NadekoBot/Commands/LoLCommands.cs index 185304c6..24eed0c7 100644 --- a/NadekoBot/Commands/LoLCommands.cs +++ b/NadekoBot/Commands/LoLCommands.cs @@ -253,7 +253,9 @@ Assists: {general["assists"]} Ban: {general["banRate"]}% var data = JObject.Parse( await Classes .SearchHelper - .GetResponseStringAsync($"http://api.champion.gg/stats/champs/mostBanned?api_key={NadekoBot.Creds.LOLAPIKey}&page=1&limit={showCount}"))["data"] as JArray; + .GetResponseStringAsync($"http://api.champion.gg/stats/champs/mostBanned?" + + $"api_key={NadekoBot.Creds.LOLAPIKey}&page=1&" + + $"limit={showCount}"))["data"] as JArray; var sb = new StringBuilder(); sb.AppendLine($"**Showing {showCount} top banned champions.**"); diff --git a/NadekoBot/Modules/Music.cs b/NadekoBot/Modules/Music.cs index d53ab660..837155c2 100644 --- a/NadekoBot/Modules/Music.cs +++ b/NadekoBot/Modules/Music.cs @@ -200,15 +200,11 @@ namespace NadekoBot.Modules { cgb.CreateCommand("setgame") .Description("Sets the game of the bot to the number of songs playing.**Owner only**") - .AddCheck(Classes.Permissions.SimpleCheckers.OwnerOnly()) + .AddCheck(SimpleCheckers.OwnerOnly()) .Do(async e => { - setgameEnabled = !setgameEnabled; - if (setgameEnabled) - setgameTimer.Start(); - else - setgameTimer.Stop(); - - await e.Channel.SendMessage("`Music status " + (setgameEnabled ? "enabled`" : "disabled`")); + await e.Channel.SendMessage("❗This command is deprecated. " + + "Use:\n `.ropl`\n `.adpl %playing% songs, %queued% queued.` instead.\n " + + "It even persists through restarts."); }); cgb.CreateCommand("pl")