From 3fa30fc4f59955f72ea10bdbe63d0ee593d9e234 Mon Sep 17 00:00:00 2001 From: MrPowerGamerBR Date: Mon, 20 Jan 2025 17:16:11 -0300 Subject: [PATCH] Smol refactor to move the page count to a variable --- .../morenitta/interactions/vanilla/economy/BrokerCommand.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/interactions/vanilla/economy/BrokerCommand.kt b/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/interactions/vanilla/economy/BrokerCommand.kt index 27852f062d..9ed99c6cd0 100644 --- a/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/interactions/vanilla/economy/BrokerCommand.kt +++ b/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/interactions/vanilla/economy/BrokerCommand.kt @@ -58,6 +58,8 @@ class BrokerCommand(val loritta: LorittaBot) : SlashCommandDeclarationWrapper { else if (LorittaBovespaBrokerUtils.checkIfTickerDataIsStale(brokerTickerInformation.lastUpdatedAt)) Emotes.Idle else Emotes.Online + + private const val TICKERS_PER_PAGE = 10 } override fun command() = slashCommand(I18N_PREFIX.Label, I18N_PREFIX.Description, CommandCategory.ECONOMY, UUID.fromString("65b54675-e0bb-43ec-948a-d6c73e57aaed")) { @@ -262,10 +264,10 @@ class BrokerCommand(val loritta: LorittaBot) : SlashCommandDeclarationWrapper { ) } - val totalPagesZeroIndexed = ceil(userStockAssets.size / 10.0).toInt() - 1 + val totalPagesZeroIndexed = ceil(userStockAssets.size / TICKERS_PER_PAGE.toDouble()).toInt() - 1 val userStockAssetsForThisPage = userStockAssets .drop(page) - .take(10) + .take(TICKERS_PER_PAGE) if (userStockAssetsForThisPage.isEmpty()) context.fail(false) {