mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Added error logging to pagination as there seems to be an issue
This commit is contained in:
@@ -228,40 +228,47 @@ public static class MessageChannelExtensions
|
|||||||
{
|
{
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
if (si is not SocketMessageComponent smc)
|
try
|
||||||
return;
|
|
||||||
|
|
||||||
if (smc.Message.Id != msg.Id)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (smc.Data.CustomId != BUTTON_LEFT && smc.Data.CustomId != BUTTON_RIGHT)
|
|
||||||
return;
|
|
||||||
|
|
||||||
await si.DeferAsync();
|
|
||||||
if (smc.User.Id != ctx.User.Id)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (smc.Data.CustomId == BUTTON_LEFT)
|
|
||||||
{
|
{
|
||||||
if (currentPage == 0)
|
if (si is not SocketMessageComponent smc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var toSend = await pageFunc(--currentPage);
|
if (smc.Message.Id != msg.Id)
|
||||||
if (addPaginatedFooter)
|
return;
|
||||||
toSend.AddPaginatedFooter(currentPage, lastPage);
|
|
||||||
|
|
||||||
await smc.ModifyOriginalResponseAsync(x => x.Embed = toSend.Build());
|
if (smc.Data.CustomId != BUTTON_LEFT && smc.Data.CustomId != BUTTON_RIGHT)
|
||||||
}
|
return;
|
||||||
else if (smc.Data.CustomId == BUTTON_RIGHT)
|
|
||||||
{
|
await si.DeferAsync();
|
||||||
if (lastPage > currentPage)
|
if (smc.User.Id != ctx.User.Id)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (smc.Data.CustomId == BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
var toSend = await pageFunc(++currentPage);
|
if (currentPage == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var toSend = await pageFunc(--currentPage);
|
||||||
if (addPaginatedFooter)
|
if (addPaginatedFooter)
|
||||||
toSend.AddPaginatedFooter(currentPage, lastPage);
|
toSend.AddPaginatedFooter(currentPage, lastPage);
|
||||||
|
|
||||||
await smc.ModifyOriginalResponseAsync(x => x.Embed = toSend.Build());
|
await smc.ModifyOriginalResponseAsync(x => x.Embed = toSend.Build());
|
||||||
}
|
}
|
||||||
|
else if (smc.Data.CustomId == BUTTON_RIGHT)
|
||||||
|
{
|
||||||
|
if (lastPage > currentPage)
|
||||||
|
{
|
||||||
|
var toSend = await pageFunc(++currentPage);
|
||||||
|
if (addPaginatedFooter)
|
||||||
|
toSend.AddPaginatedFooter(currentPage, lastPage);
|
||||||
|
|
||||||
|
await smc.ModifyOriginalResponseAsync(x => x.Embed = toSend.Build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex, "Error in pagination: {ErrorMessage}", ex.Message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user