Fixes. .lq will say at the top if it's stopped. .lq will also default to the page current song is playing from

This commit is contained in:
Master Kwoth
2017-07-02 17:15:34 +02:00
parent 1d1b7de20a
commit 728aeab809
5 changed files with 15 additions and 21 deletions

View File

@ -181,11 +181,10 @@ namespace NadekoBot.Modules.Music
try { await msg.DeleteAsync().ConfigureAwait(false); } catch { }
}
}
//todo, page should default to the page the current song is on
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task ListQueue(int page = 1)
public async Task ListQueue(int page = 0)
{
var mp = await _music.GetOrCreatePlayer(Context);
var (current, songs) = mp.QueueArray();
@ -195,14 +194,18 @@ namespace NadekoBot.Modules.Music
await ReplyErrorLocalized("no_player").ConfigureAwait(false);
return;
}
if (--page < 0)
if (--page < -1)
return;
//todo say whether music player is stopped
//try { await musicPlayer.UpdateSongDurationsAsync().ConfigureAwait(false); } catch { }
const int itemsPerPage = 10;
if (page == -1)
page = current / itemsPerPage;
//if page is 0 (-1 after this decrement) that means default to the page current song is playing from
//var total = musicPlayer.TotalPlaytime;
//var totalStr = total == TimeSpan.MaxValue ? "∞" : GetText("time_format",
// (int)total.TotalHours,
@ -228,6 +231,8 @@ namespace NadekoBot.Modules.Music
desc = $"`🔊` {songs[current].PrettyFullName}\n\n" + desc;
var add = "";
if (mp.Stopped)
add += Format.Bold(GetText("queue_stopped", Format.Code(Prefix + "play"))) + "\n";
if (mp.RepeatCurrentSong)
add += "🔂 " + GetText("repeating_cur_song") + "\n";
else if (mp.Shuffle)
@ -345,7 +350,7 @@ namespace NadekoBot.Modules.Music
}
catch (ArgumentOutOfRangeException)
{
//todo error message
await ReplyErrorLocalized("removed_song_error").ConfigureAwait(false);
}
}