Small pagination bugfix

This commit is contained in:
Master Kwoth
2017-10-17 16:10:51 +02:00
parent 88f92cbec6
commit e54ceba0ab
14 changed files with 28 additions and 30 deletions

View File

@ -55,15 +55,17 @@ namespace NadekoBot.Extensions
private static readonly IEmote arrow_left = new Emoji("⬅");
private static readonly IEmote arrow_right = new Emoji("➡");
public static Task SendPaginatedConfirmAsync(this IMessageChannel channel, DiscordSocketClient client, int currentPage, Func<int, EmbedBuilder> pageFunc, int? lastPage = null, bool addPaginatedFooter = true) =>
channel.SendPaginatedConfirmAsync(client, currentPage, (x) => Task.FromResult(pageFunc(x)), lastPage, addPaginatedFooter);
public static Task SendPaginatedConfirmAsync(this IMessageChannel channel, DiscordSocketClient client, int currentPage, Func<int, EmbedBuilder> pageFunc, int totalElements, int itemsPerPage, bool addPaginatedFooter = true) =>
channel.SendPaginatedConfirmAsync(client, currentPage, (x) => Task.FromResult(pageFunc(x)), totalElements, itemsPerPage, addPaginatedFooter);
/// <summary>
/// danny kamisama
/// </summary>
public static async Task SendPaginatedConfirmAsync(this IMessageChannel channel, DiscordSocketClient client, int currentPage, Func<int, Task<EmbedBuilder>> pageFunc, int? lastPage = null, bool addPaginatedFooter = true)
public static async Task SendPaginatedConfirmAsync(this IMessageChannel channel, DiscordSocketClient client, int currentPage, Func<int, Task<EmbedBuilder>> pageFunc, int totalElements, int itemsPerPage, bool addPaginatedFooter = true)
{
var embed = await pageFunc(currentPage).ConfigureAwait(false);
var lastPage = (totalElements - 1) / itemsPerPage;
if (addPaginatedFooter)
embed.AddPaginatedFooter(currentPage, lastPage);
@ -93,7 +95,7 @@ namespace NadekoBot.Extensions
}
else if (r.Emote.Name == arrow_right.Name)
{
if (lastPage == null || lastPage > currentPage)
if (lastPage > currentPage)
{
var toSend = await pageFunc(++currentPage).ConfigureAwait(false);
if (addPaginatedFooter)