From 728aeab8093687ecf38654c5a12a49df434bd506 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Sun, 2 Jul 2017 17:15:34 +0200 Subject: [PATCH] Fixes. .lq will say at the top if it's stopped. .lq will also default to the page current song is playing from --- src/NadekoBot/Modules/Music/Music.cs | 19 ++++++++++++------- .../Services/Games/ChatterbotService.cs | 1 - src/NadekoBot/Services/Music/MusicPlayer.cs | 3 ++- src/NadekoBot/Services/Music/MusicService.cs | 12 ------------ .../_strings/ResponseStrings.en-US.json | 1 + 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/NadekoBot/Modules/Music/Music.cs b/src/NadekoBot/Modules/Music/Music.cs index a56d5cfa..fbd01028 100644 --- a/src/NadekoBot/Modules/Music/Music.cs +++ b/src/NadekoBot/Modules/Music/Music.cs @@ -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); } } diff --git a/src/NadekoBot/Services/Games/ChatterbotService.cs b/src/NadekoBot/Services/Games/ChatterbotService.cs index 833eef0b..7f9c8251 100644 --- a/src/NadekoBot/Services/Games/ChatterbotService.cs +++ b/src/NadekoBot/Services/Games/ChatterbotService.cs @@ -104,7 +104,6 @@ namespace NadekoBot.Services.Games { if (pc.Verbose) { - //todo move this to permissions var returnMsg = _strings.GetText("trigger", guild.Id, "Permissions".ToLowerInvariant(), index + 1, Format.Bold(pc.Permissions[index].GetCommand(_cmd.GetPrefix(guild), (SocketGuild)guild))); try { await usrMsg.Channel.SendErrorAsync(returnMsg).ConfigureAwait(false); } catch { } _log.Info(returnMsg); diff --git a/src/NadekoBot/Services/Music/MusicPlayer.cs b/src/NadekoBot/Services/Music/MusicPlayer.cs index 48a037be..e9f10ab3 100644 --- a/src/NadekoBot/Services/Music/MusicPlayer.cs +++ b/src/NadekoBot/Services/Music/MusicPlayer.cs @@ -174,7 +174,6 @@ namespace NadekoBot.Services.Music try { _log.Info("Loading related song"); - //todo test autoplay await _musicService.TryQueueRelatedSongAsync(data.Song.Query, OutputTextChannel, VoiceChannel); Queue.Next(); } @@ -245,6 +244,8 @@ namespace NadekoBot.Services.Music manualSkip = true; // if player is stopped, and user uses .n, it should play current song. // It's a bit weird, but that's the least annoying solution + if (!Stopped) + Queue.Next(skipCount - 1); Stopped = false; Unpause(); CancelCurrentSong(); diff --git a/src/NadekoBot/Services/Music/MusicService.cs b/src/NadekoBot/Services/Music/MusicService.cs index ccc70dbc..03f7b0d9 100644 --- a/src/NadekoBot/Services/Music/MusicService.cs +++ b/src/NadekoBot/Services/Music/MusicService.cs @@ -108,18 +108,6 @@ namespace NadekoBot.Services.Music { // ignored } - - //todo autoplay should be independent from event handlers - //if (mp.Autoplay && mp.Playlist.Count == 0 && song.SongInfo.ProviderType == MusicType.Normal) - //{ - // var relatedVideos = (await _google.GetRelatedVideosAsync(song.SongInfo.Query, 4)).ToList(); - // if (relatedVideos.Count > 0) - // await QueueSong(await textCh.Guild.GetCurrentUserAsync(), - // textCh, - // voiceCh, - // relatedVideos[new NadekoRandom().Next(0, relatedVideos.Count)], - // true).ConfigureAwait(false); - //} } catch { diff --git a/src/NadekoBot/_strings/ResponseStrings.en-US.json b/src/NadekoBot/_strings/ResponseStrings.en-US.json index a83d8442..705b3c34 100644 --- a/src/NadekoBot/_strings/ResponseStrings.en-US.json +++ b/src/NadekoBot/_strings/ResponseStrings.en-US.json @@ -440,6 +440,7 @@ "music_queue_full": "Queue is full at {0}/{0}.", "music_queue_stopped": "Player is stopped. Use {0} command to start playing.", "music_removed_song": "Removed song", + "music_removed_song_error": "Song on that index doesn't exist", "music_repeating_cur_song": "Repeating current song", "music_repeating_playlist": "Repeating playlist", "music_repeating_track": "Repeating track",