added !m rm all, changes to music

This commit is contained in:
Master Kwoth 2016-02-20 17:38:02 +01:00
parent a0ec4db004
commit 5da3492b12
2 changed files with 15 additions and 8 deletions

View File

@ -205,7 +205,7 @@ namespace NadekoBot.Classes.Music {
buffer.Position = newPos;
}
}
int blockSize = 1024;
int blockSize = 2048;
var buf = new byte[blockSize];
int read = 0;
read = await p.StandardOutput.BaseStream.ReadAsync(buf, 0, blockSize);
@ -213,8 +213,7 @@ namespace NadekoBot.Classes.Music {
if (read == 0) {
if (attempt == 5) {
try {
p.CancelOutputRead();
p.Close();
p.Dispose();
}
catch { }
@ -242,7 +241,7 @@ namespace NadekoBot.Classes.Music {
if (parent.OnBuffering != null)
parent.OnBuffering();
Task.Factory.StartNew(async () => {
Task.Run(async () => {
await BufferSong();
}).ConfigureAwait(false);
@ -301,7 +300,7 @@ namespace NadekoBot.Classes.Music {
parent.MusicControls.VoiceClient.Send(voiceBuffer, 0, readCount);
while (IsPaused) {
await Task.Delay(50);
await Task.Delay(100);
}
}
parent.MusicControls.VoiceClient.Wait();

View File

@ -225,13 +225,21 @@ namespace NadekoBot.Modules {
});
cgb.CreateCommand("rm")
.Description("Removes a song by a # from the queue")
.Description("Removes a song by a # from the queue or 'all' to remove whole queue.")
.Parameter("num",ParameterType.Required)
.Do(async e => {
var arg = e.GetArg("num");
int num;
MusicControls mc;
if (!musicPlayers.TryGetValue(e.Server, out mc) || !int.TryParse(arg, out num)) {
if (!musicPlayers.TryGetValue(e.Server, out mc)) {
return;
}
if (arg?.ToLower() == "all") {
mc.SongQueue?.Clear();
await e.Send($"🎵Queue cleared!");
return;
}
int num;
if (!int.TryParse(arg, out num)) {
return;
}
if (num <= 0 || num > mc.SongQueue.Count)