From 7941bdc13db99aa29a19ee3a2f902da5a6782b77 Mon Sep 17 00:00:00 2001 From: MrPowerGamerBR Date: Wed, 29 Jan 2025 18:47:11 -0300 Subject: [PATCH] Fix third party sonhos transaction taxes and improve wording in some of the messages --- ...artyPaymentSonhosTransactionTransformer.kt | 6 ++-- .../SonhosTransferInteractionsListener.kt | 2 -- ...PartySonhosTransferInteractionsListener.kt | 32 +++++++++++++++---- resources/languages/pt/commands/pay.yml | 4 ++- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/interactions/vanilla/economy/transactiontransformers/ThirdPartyPaymentSonhosTransactionTransformer.kt b/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/interactions/vanilla/economy/transactiontransformers/ThirdPartyPaymentSonhosTransactionTransformer.kt index 5c8fb0f5e6..fc2ace9e0f 100644 --- a/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/interactions/vanilla/economy/transactiontransformers/ThirdPartyPaymentSonhosTransactionTransformer.kt +++ b/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/interactions/vanilla/economy/transactiontransformers/ThirdPartyPaymentSonhosTransactionTransformer.kt @@ -41,8 +41,8 @@ object ThirdPartyPaymentSonhosTransactionTransformer : SonhosTransactionTransfor append( i18nContext.get( SonhosCommand.TRANSACTIONS_I18N_PREFIX.Types.Payment.ThirdPartyReceived( - transaction.sonhos + transaction.tax, transaction.sonhos, + transaction.sonhos - transaction.tax, convertToUserNameCodeBlockPreviewTag( transaction.givenBy.value.toLong(), giverUserInfo?.name, @@ -76,8 +76,8 @@ object ThirdPartyPaymentSonhosTransactionTransformer : SonhosTransactionTransfor append( i18nContext.get( SonhosCommand.TRANSACTIONS_I18N_PREFIX.Types.Payment.ThirdPartySent( - transaction.sonhos + transaction.tax, transaction.sonhos, + transaction.sonhos - transaction.tax, convertToUserNameCodeBlockPreviewTag( transaction.receivedBy.value.toLong(), receiverUserInfo?.name, @@ -92,7 +92,7 @@ object ThirdPartyPaymentSonhosTransactionTransformer : SonhosTransactionTransfor append( i18nContext.get( SonhosCommand.TRANSACTIONS_I18N_PREFIX.Types.Payment.ThirdPartySentNoTax( - transaction.sonhos + transaction.tax, + transaction.sonhos, convertToUserNameCodeBlockPreviewTag( transaction.receivedBy.value.toLong(), receiverUserInfo?.name, diff --git a/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/listeners/SonhosTransferInteractionsListener.kt b/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/listeners/SonhosTransferInteractionsListener.kt index 18ecc079ce..edcbefaf1a 100644 --- a/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/listeners/SonhosTransferInteractionsListener.kt +++ b/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/listeners/SonhosTransferInteractionsListener.kt @@ -138,8 +138,6 @@ class SonhosTransferInteractionsListener(val loritta: LorittaBot) : ListenerAdap it[PaymentSonhosTransactionResults.timestamp] = now } - val serializedMetadata = sonhosTransferRequestData[SonhosTransferRequests.metadata] - val storedTransaction = StoredPaymentSonhosTransaction( giverProfile.id.value.toLong(), receiverProfile.id.value.toLong(), diff --git a/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/listeners/ThirdPartySonhosTransferInteractionsListener.kt b/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/listeners/ThirdPartySonhosTransferInteractionsListener.kt index f191bc2d32..dc1fc2ef02 100644 --- a/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/listeners/ThirdPartySonhosTransferInteractionsListener.kt +++ b/loritta-bot-discord/src/main/kotlin/net/perfectdreams/loritta/morenitta/listeners/ThirdPartySonhosTransferInteractionsListener.kt @@ -106,8 +106,8 @@ class ThirdPartySonhosTransferInteractionsListener(val loritta: LorittaBot) : Li if (giverHasAccepted && receiverHasAccepted) { val howMuch = sonhosTransferRequestData[ThirdPartySonhosTransferRequests.quantity] - val howMuchShouldBeRemoved = howMuch + sonhosTransferRequestData[ThirdPartySonhosTransferRequests.tax] - val howMuchShouldBeAdded = sonhosTransferRequestData[ThirdPartySonhosTransferRequests.quantity] + val howMuchShouldBeRemoved = howMuch + val howMuchShouldBeAdded = sonhosTransferRequestData[ThirdPartySonhosTransferRequests.quantity] - sonhosTransferRequestData[ThirdPartySonhosTransferRequests.tax] val receiverProfile = loritta.pudding.users.getOrCreateUserProfile( net.perfectdreams.loritta.serializable.UserId(sonhosTransferRequestData[ThirdPartySonhosTransferRequests.receiver]) @@ -182,6 +182,7 @@ class ThirdPartySonhosTransferInteractionsListener(val loritta: LorittaBot) : Li sonhosTransferRequestData[ThirdPartySonhosTransferRequests.receiver], sonhosTransferRequestData[ThirdPartySonhosTransferRequests.giver], howMuch, + sonhosTransferRequestData[ThirdPartySonhosTransferRequests.tax], updatedReceiverProfile.money, receiverRanking, updatedGiverProfile.money, @@ -221,10 +222,28 @@ class ThirdPartySonhosTransferInteractionsListener(val loritta: LorittaBot) : Li user(result.receiverId) } - styled( - i18nContext.get(SonhosCommand.PAY_I18N_PREFIX.SuccessfullyTransferred("<@${result.receiverId}>", result.howMuch)), - Emotes.Handshake - ) + if (result.tax != 0L) { + styled( + i18nContext.get( + SonhosCommand.PAY_I18N_PREFIX.ThirdPartySuccessfullyTransferred( + "<@${result.receiverId}>", + result.howMuch - result.tax, + result.tax + ) + ), + Emotes.Handshake + ) + } else { + styled( + i18nContext.get( + SonhosCommand.PAY_I18N_PREFIX.ThirdPartySuccessfullyTransferredNoTax( + "<@${result.receiverId}>", + result.howMuch + ) + ), + Emotes.Handshake + ) + } // Let's add a random emoji just to look cute val user1Emote = SonhosUtils.HANGLOOSE_EMOTES.random() @@ -341,6 +360,7 @@ class ThirdPartySonhosTransferInteractionsListener(val loritta: LorittaBot) : Li val receiverId: Long, val giverId: Long, val howMuch: Long, + val tax: Long, val receiverQuantity: Long, val receiverRanking: Long?, val giverQuantity: Long, diff --git a/resources/languages/pt/commands/pay.yml b/resources/languages/pt/commands/pay.yml index af8df14fc0..05d608c04e 100644 --- a/resources/languages/pt/commands/pay.yml +++ b/resources/languages/pt/commands/pay.yml @@ -4,7 +4,7 @@ acceptTransfer: "Aceitar Transferência ({acceptedQuantity,number}/2)" cancel: "Cancelar" youAreGoingToTransfer: "Você está prestes a transferir **{sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}}** para {receiver}!" -thirdPartyIsGoingToTransfer: "{sender} está prestes a transferir **{sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} ({sonhosTaxQuantity,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} de taxa)** para {receiver}!" +thirdPartyIsGoingToTransfer: "{sender} está prestes a transferir **{sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} (dos {sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}}, {sonhosTaxQuantity,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} são de taxa)** para {receiver}!" thirdPartyIsGoingToTransferNoTax: "{sender} está prestes a transferir **{sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} (sem precisar pagar taxa!)** para {receiver}!" confirmTheTransaction: "Para confirmar a transação, você e {receiver} devem aceitar a transação até {time} ({timeRelative})!" @@ -13,6 +13,8 @@ transferAccepted: "Transferência Aceita" transferFailed: "Transferência Falhou - {failReason}" transferCancelled: "Transferência Cancelada" successfullyTransferred: "Transferência realizada com sucesso! {receiver} recebeu **{sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}}**!" +thirdPartySuccessfullyTransferred: "Transferência realizada com sucesso! {receiver} recebeu **{sonhosAfterTax,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} (e {tax,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} foram para o governo)**!" +thirdPartySuccessfullyTransferredNoTax: "Transferência realizada com sucesso! {receiver} recebeu **{sonhosAfterTax,plural, =0 {# sonhos} one {# sonho} other {# sonhos}} (e o governo recebeu nadinha de taxa)**!" transferredSonhos: "{user} agora possui {sonhosEmoji} **{sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}}**!" transferredSonhosWithRanking: "{user} agora possui {sonhosEmoji} **{sonhos,plural, =0 {# sonhos} one {# sonho} other {# sonhos}}** e está em **#{rankingPosition,number} lugar** no ranking!" selfAccountIsTooNew: "Espere aí, a sua conta é muito nova! Antes de poder transferir sonhos, você precisa aguardar até {time} ({timeRelative}) antes de começar a transferir sonhos."