fix pages

This commit is contained in:
Mylloon 2023-01-16 18:59:17 +01:00
parent 2e1b350e15
commit 240b0d0422
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -281,11 +281,10 @@ export const embedListReminders = async (client: Client, user: User, guildId: st
const reminders = await listReminders(client, user.id, guildId); const reminders = await listReminders(client, user.id, guildId);
const elementPerPage = 5; const elementPerPage = 5;
let pageMax = Math.floor(reminders.length / elementPerPage); const pageMax = Math.ceil(reminders.length / elementPerPage);
if (pageMax <= 1) { if (pageMax <= 1) {
page = 1; page = 1;
pageMax = 1;
} }
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setColor(Colors.DarkGrey) .setColor(Colors.DarkGrey)
@ -295,9 +294,10 @@ export const embedListReminders = async (client: Client, user: User, guildId: st
const limit = elementPerPage * page; const limit = elementPerPage * page;
if (reminders.length > 0 && page <= pageMax) { if (reminders.length > 0 && page <= pageMax) {
let curseur = limit - elementPerPage - 1; let curseur = limit - elementPerPage;
reminders.splice(0, limit - elementPerPage);
reminders.forEach((remind) => { reminders.forEach((remind) => {
if (curseur <= limit) { if (curseur < limit) {
let text = remind.data ?? loc.get('c_reminder7'); let text = remind.data ?? loc.get('c_reminder7');
if (text.length > 1024) { if (text.length > 1024) {
text = `${text.substring(0, 1021)}...`; text = `${text.substring(0, 1021)}...`;