From 951cb87a82395fe3af5cd51ed3bbff56d04d7fb8 Mon Sep 17 00:00:00 2001 From: derpystuff <3515180-derpystuff@users.noreply.gitlab.com> Date: Tue, 28 Jun 2022 17:54:08 +0200 Subject: [PATCH] dont create paginator for one page --- labscore/paginator/structures/BasePaginator.js | 3 +++ labscore/paginator/structures/Paginator.js | 10 ++++++++++ labscore/utils/embed.js | 3 +++ 3 files changed, 16 insertions(+) diff --git a/labscore/paginator/structures/BasePaginator.js b/labscore/paginator/structures/BasePaginator.js index 1e8056c..3492f1d 100644 --- a/labscore/paginator/structures/BasePaginator.js +++ b/labscore/paginator/structures/BasePaginator.js @@ -52,8 +52,11 @@ module.exports = class BasePaginator extends EventEmitter { // Create Components let msg = this.pages[this.index]; msg.components = await this.client.components(this) + + // Ensure there are no mentions if(!msg.message_reference) msg.reference = true if(!msg.allowedMentions) msg.allowedMentions = {parse: [], repliedUser: false} + return this.commandMessage = await this.editOrReply(msg); } diff --git a/labscore/paginator/structures/Paginator.js b/labscore/paginator/structures/Paginator.js index ef64d68..7070bf0 100644 --- a/labscore/paginator/structures/Paginator.js +++ b/labscore/paginator/structures/Paginator.js @@ -158,6 +158,16 @@ module.exports = class Paginator { } if(listener) await listener.stop() + // No need for a paginator if we only have one page. + if(data.pages.length == 1){ + let msg = data.pages[0]; + + if(!msg.message_reference) msg.reference = true + if(!msg.allowedMentions) msg.allowedMentions = {parse: [], repliedUser: false} + + return await data.context.editOrReply(msg); + } + const instance = new InteractionPaginator(this, data); this.activeListeners.push(instance); diff --git a/labscore/utils/embed.js b/labscore/utils/embed.js index 8ecacce..6299706 100644 --- a/labscore/utils/embed.js +++ b/labscore/utils/embed.js @@ -77,6 +77,9 @@ module.exports.createEmbed = function(type, context, content){ // Adds formatted page numbers to the embed footer module.exports.formatPaginationEmbeds = function(embeds){ + // No formatting if we only have one page + if(embeds.length == 1) return embeds; + let i = 0; let l = embeds.length; let formatted = [];