fix #967 !!ap fix, !!lq fix (it shows info in footer again)

This commit is contained in:
Kwoth 2017-01-14 18:25:08 +01:00
parent e4bcb5a713
commit 659ba913a1
3 changed files with 27 additions and 11 deletions

View File

@ -140,9 +140,15 @@ namespace NadekoBot.Modules.Music.Classes
RemoveSongAt(index, true); RemoveSongAt(index, true);
OnStarted(this, CurrentSong); OnStarted(this, CurrentSong);
await CurrentSong.Play(audioClient, cancelToken); try
{
await CurrentSong.Play(audioClient, cancelToken);
}
catch(OperationCanceledException)
{
OnCompleted(this, CurrentSong);
}
OnCompleted(this, CurrentSong);
if (RepeatPlaylist) if (RepeatPlaylist)
AddSong(CurrentSong, CurrentSong.QueuerName); AddSong(CurrentSong, CurrentSong.QueuerName);
@ -151,7 +157,6 @@ namespace NadekoBot.Modules.Music.Classes
AddSong(CurrentSong, 0); AddSong(CurrentSong, 0);
} }
catch (OperationCanceledException) { }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("Music thread almost crashed."); Console.WriteLine("Music thread almost crashed.");

View File

@ -192,7 +192,7 @@ namespace NadekoBot.Modules.Music
int startAt = itemsPerPage * (curPage - 1); int startAt = itemsPerPage * (curPage - 1);
var number = 0 + startAt; var number = 0 + startAt;
var embed = new EmbedBuilder() var embed = new EmbedBuilder()
.WithAuthor(eab => eab.WithName($"Player Queue") .WithAuthor(eab => eab.WithName($"Player Queue - Page {curPage}/{lastPage + 1}")
.WithMusicIcon()) .WithMusicIcon())
.WithDescription(string.Join("\n", musicPlayer.Playlist .WithDescription(string.Join("\n", musicPlayer.Playlist
.Skip(startAt) .Skip(startAt)
@ -217,7 +217,7 @@ namespace NadekoBot.Modules.Music
} }
return embed; return embed;
}; };
await Context.Channel.SendPaginatedConfirmAsync(page, printAction, lastPage).ConfigureAwait(false); await Context.Channel.SendPaginatedConfirmAsync(page, printAction, lastPage, false).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
@ -814,7 +814,7 @@ namespace NadekoBot.Modules.Music
.WithFooter(ef => ef.WithText(song.PrettyInfo))) .WithFooter(ef => ef.WithText(song.PrettyInfo)))
.ConfigureAwait(false); .ConfigureAwait(false);
if (mp.Autoplay && mp.Playlist.Count == 0 && song.SongInfo.Provider == "YouTube") if (mp.Autoplay && mp.Playlist.Count == 0 && song.SongInfo.ProviderType == MusicType.Normal)
{ {
await QueueSong(await queuer.Guild.GetCurrentUserAsync(), textCh, voiceCh, (await NadekoBot.Google.GetRelatedVideosAsync(song.SongInfo.Query, 4)).ToList().Shuffle().FirstOrDefault(), silent, musicType).ConfigureAwait(false); await QueueSong(await queuer.Guild.GetCurrentUserAsync(), textCh, voiceCh, (await NadekoBot.Google.GetRelatedVideosAsync(song.SongInfo.Query, 4)).ToList().Shuffle().FirstOrDefault(), silent, musicType).ConfigureAwait(false);
} }

View File

@ -24,10 +24,13 @@ namespace NadekoBot.Extensions
/// <summary> /// <summary>
/// danny kamisama /// danny kamisama
/// </summary> /// </summary>
public static async Task SendPaginatedConfirmAsync(this IMessageChannel channel, int currentPage, Func<int, EmbedBuilder> pageFunc, int? lastPage = null) public static async Task SendPaginatedConfirmAsync(this IMessageChannel channel, int currentPage, Func<int, EmbedBuilder> pageFunc, int? lastPage = null, bool addPaginatedFooter = true)
{ {
lastPage += 1; lastPage += 1;
var embed = pageFunc(currentPage).AddPaginatedFooter(currentPage, lastPage); var embed = pageFunc(currentPage);
if(addPaginatedFooter)
embed.AddPaginatedFooter(currentPage, lastPage);
var msg = await channel.EmbedAsync(embed) as IUserMessage; var msg = await channel.EmbedAsync(embed) as IUserMessage;
@ -47,12 +50,20 @@ namespace NadekoBot.Extensions
{ {
if (currentPage == 1) if (currentPage == 1)
return; return;
await msg.ModifyAsync(x => x.Embed = pageFunc(--currentPage).AddPaginatedFooter(currentPage, lastPage).Build()).ConfigureAwait(false); var toSend = pageFunc(--currentPage);
if (addPaginatedFooter)
toSend.AddPaginatedFooter(currentPage, lastPage);
await msg.ModifyAsync(x => x.Embed = toSend.Build()).ConfigureAwait(false);
} }
else if (r.Emoji.Name == arrow_right) else if (r.Emoji.Name == arrow_right)
{ {
if (lastPage == null || lastPage > currentPage) if (lastPage == null || lastPage > currentPage)
await msg.ModifyAsync(x => x.Embed = pageFunc(++currentPage).AddPaginatedFooter(currentPage, lastPage).Build()).ConfigureAwait(false); {
var toSend = pageFunc(++currentPage);
if (addPaginatedFooter)
toSend.AddPaginatedFooter(currentPage, lastPage);
await msg.ModifyAsync(x => x.Embed = toSend.Build()).ConfigureAwait(false);
}
} }
} }
catch (Exception ex) { Console.WriteLine(ex); } catch (Exception ex) { Console.WriteLine(ex); }