lq, q nicer txt, fixed .prune > 100

This commit is contained in:
Master Kwoth
2016-01-30 12:08:30 +01:00
parent 171d3cd4ab
commit efc2810f22
7 changed files with 73 additions and 47 deletions

View File

@ -300,7 +300,14 @@ namespace NadekoBot.Modules {
return;
}
try {
(await e.Channel.DownloadMessages(num)).ForEach(async m => await m.Delete());
var msgs = await e.Channel.DownloadMessages(100);
var lastmessage = e.Channel.Messages.LastOrDefault();
while (num > 0 && lastmessage!=null) {
msgs.ForEach(async m => await m.Delete());
num -= 100;
lastmessage = msgs.LastOrDefault();
msgs = await e.Channel.DownloadMessages(100, lastmessage?.Id);
}
} catch (Exception) { await e.Send("Failed pruning. Make sure the bot has correct permissions."); }
});
@ -322,9 +329,7 @@ namespace NadekoBot.Modules {
.Description("Clears some of nadeko's messages from the current channel.")
.Do(async e => {
try {
if (e.Channel.Messages.Count() < 50) {
await e.Channel.DownloadMessages(100);
}
await e.Channel.DownloadMessages(100);
e.Channel.Messages.Where(msg => msg.User.Id == client.CurrentUser.Id).ForEach(async m => await m.Delete());

View File

@ -96,21 +96,22 @@ namespace NadekoBot.Modules {
if (sr == null)
throw new NullReferenceException("StreamRequest is null.");
Message msg = null;
Message qmsg = null;
sr.OnQueued += async () => {
msg = await e.Send($":musical_note:**Queued** {sr.Title}");
qmsg = await e.Send($":musical_note:**Queued** {sr.Title.TrimTo(55)}");
};
sr.OnCompleted += async () => {
await e.Send($":musical_note:**Finished playing** {sr.Title}");
await e.Send($":musical_note:**Finished playing** {sr.Title.TrimTo(55)}");
};
sr.OnStarted += async () => {
if (msg == null)
await e.Send($":musical_note:**Starting playback of** {sr.Title}");
await e.Send($":musical_note:**Playing ** {sr.Title.TrimTo(55)}");
else
await msg.Edit($":musical_note:**Starting playback of** {sr.Title}");
await msg.Edit($":musical_note:**Playing ** {sr.Title.TrimTo(55)}");
qmsg?.Delete();
};
sr.OnBuffering += async () => {
if (msg != null)
msg = await e.Send($":musical_note:**Buffering the song**...{sr.Title}");
msg = await e.Send($":musical_note:**Buffering...** {sr.Title.TrimTo(55)}");
};
} catch (Exception ex) {
Console.WriteLine();
@ -127,7 +128,8 @@ namespace NadekoBot.Modules {
var player = musicPlayers[e.Server];
await e.Send(":musical_note: " + player.SongQueue.Count + " videos currently queued.");
await e.Send(string.Join("\n", player.SongQueue.Select(v => v.Title).Take(10)));
int number = 1;
await e.Send(string.Join("\n", player.SongQueue.Select(v => $"**#{number++}** {v.Title.TrimTo(60)}").Take(10)));
});
cgb.CreateCommand("np")