Skip to content

Commit

Permalink
Do not defer the accept transactions button
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPowerGamerBR committed Oct 19, 2024
1 parent c953553 commit 9d69221
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import net.perfectdreams.loritta.common.utils.TransactionType
import net.perfectdreams.loritta.morenitta.LorittaBot
import net.perfectdreams.loritta.morenitta.interactions.vanilla.economy.SonhosCommand
import net.perfectdreams.loritta.morenitta.interactions.vanilla.economy.SonhosPayExecutor
import net.perfectdreams.loritta.morenitta.interactions.vanilla.economy.SonhosPayExecutor.Companion.SONHOS_TRANSFER_ACCEPT_COMPONENT_PREFIX
import net.perfectdreams.loritta.morenitta.utils.extensions.await
import net.perfectdreams.loritta.morenitta.utils.extensions.toJDA
import net.perfectdreams.loritta.serializable.StoredPaymentSonhosTransaction
Expand All @@ -39,8 +38,9 @@ class SonhosTransferInteractionsListener(val loritta: LorittaBot) : ListenerAdap
val dbId = event.componentId.substringAfter(":").toLong()

GlobalScope.launch {
val deferredReply = event.interaction.deferEdit().await()

// WE DO NOT DEFER THE MESSAGE BECAUSE THAT WILL HORRIBLE ISSUES!!!
// Horrible issues = users SPAMMING the message causing SHARED RATE LIMITS that cannot be properly ratelimited by nirn-proxy or JDA because THERE ISN'T ANYTHING ON THE PATH
// TO LET THE LIBRARY WAIT THE REQUEST
val i18nContext = if (guild != null) {
val serverConfig = loritta.getOrCreateServerConfig(guild.idLong, true)
loritta.languageManager.getI18nContextByLegacyLocaleId(serverConfig.localeId)
Expand Down Expand Up @@ -199,7 +199,7 @@ class SonhosTransferInteractionsListener(val loritta: LorittaBot) : ListenerAdap
when (result) {
is TransferResult.Success -> {
// Let's go!!
deferredReply.editOriginal(
val hook = event.editMessage(
MessageEdit {
actionRow(
Button.of(
Expand All @@ -212,7 +212,7 @@ class SonhosTransferInteractionsListener(val loritta: LorittaBot) : ListenerAdap
}
).setReplace(false).await()

deferredReply.sendMessage(
hook.sendMessage(
MessageCreate {
mentions {
// Allow mentioning the giver AND the receiver!
Expand Down Expand Up @@ -255,12 +255,12 @@ class SonhosTransferInteractionsListener(val loritta: LorittaBot) : ListenerAdap
).await()
}
is TransferResult.RequestUpdated -> {
deferredReply.editOriginal(
event.editMessage(
MessageEdit {
actionRow(
Button.of(
ButtonStyle.PRIMARY,
"$SONHOS_TRANSFER_ACCEPT_COMPONENT_PREFIX:${dbId}",
"${SonhosPayExecutor.SONHOS_TRANSFER_ACCEPT_COMPONENT_PREFIX}:${dbId}",
i18nContext.get(SonhosCommand.PAY_I18N_PREFIX.AcceptTransfer(result.quantityApproved)),
Emotes.Handshake.toJDA()
)
Expand All @@ -269,7 +269,7 @@ class SonhosTransferInteractionsListener(val loritta: LorittaBot) : ListenerAdap
).setReplace(false).await()
}
TransferResult.AlreadyTransferred -> {
deferredReply.sendMessage(
event.reply(
MessageCreate {
styled(
i18nContext.get(SonhosCommand.PAY_I18N_PREFIX.ThisTransactionHasAlreadyBeenTransferred),
Expand All @@ -279,7 +279,7 @@ class SonhosTransferInteractionsListener(val loritta: LorittaBot) : ListenerAdap
).setEphemeral(true).await()
}
TransferResult.NotEnoughSonhos -> {
deferredReply.editOriginal(
event.editMessage(
MessageEdit {
actionRow(
Button.of(
Expand All @@ -293,7 +293,7 @@ class SonhosTransferInteractionsListener(val loritta: LorittaBot) : ListenerAdap
).setReplace(false).await()
}
TransferResult.NotTheUser -> {
deferredReply.sendMessage(
event.reply(
MessageCreate {
styled(
i18nContext.get(SonhosCommand.PAY_I18N_PREFIX.YouArentInvolvedInThisTransaction),
Expand All @@ -303,7 +303,7 @@ class SonhosTransferInteractionsListener(val loritta: LorittaBot) : ListenerAdap
).setEphemeral(true).await()
}
TransferResult.RequestExpired -> {
deferredReply.editOriginal(
event.editMessage(
MessageEdit {
actionRow(
Button.of(
Expand All @@ -317,7 +317,7 @@ class SonhosTransferInteractionsListener(val loritta: LorittaBot) : ListenerAdap
).setReplace(false).await()
}
TransferResult.UnknownRequest -> {
deferredReply.editOriginal(
event.editMessage(
MessageEdit {
actionRow(
Button.of(
Expand Down

0 comments on commit 9d69221

Please sign in to comment.