fixed permissions, depercated !M setgame, debugging stuff

This commit is contained in:
Master Kwoth 2016-03-07 09:17:15 +01:00
parent 86a140f8bb
commit 638ddbd3b1
4 changed files with 21 additions and 11 deletions

View File

@ -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

View File

@ -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));
}

View File

@ -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.**");

View File

@ -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")