Skip to content

Commit

Permalink
Ignore if the daily check content is so large that it exceeds the max…
Browse files Browse the repository at this point in the history
… message size
  • Loading branch information
MrPowerGamerBR committed Jul 17, 2024
1 parent 12aa837 commit a5b19fd
Showing 1 changed file with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import net.dv8tion.jda.api.utils.FileUpload
import net.perfectdreams.loritta.cinnamon.pudding.tables.BannedUsers
import net.perfectdreams.loritta.cinnamon.pudding.tablesrefactorlater.BrowserFingerprints
import net.perfectdreams.loritta.cinnamon.pudding.tablesrefactorlater.Dailies
import net.perfectdreams.loritta.common.utils.text.TextUtils.shortenWithEllipsis
import net.perfectdreams.loritta.helper.LorittaHelper
import net.perfectdreams.loritta.helper.utils.Constants
import net.perfectdreams.loritta.morenitta.interactions.commands.*
Expand Down Expand Up @@ -142,7 +143,7 @@ class DailyCheckCommand(val helper: LorittaHelper) : SlashCommandDeclarationWrap
}

context.reply(true) {
content = buildString {
val messageContent = buildString {
val moreThanOneUsersMatches = matchedSameClientIds.filter { it.value.size > 1 }
if (moreThanOneUsersMatches.isNotEmpty()) {
appendLine("**Loritta Client IDs com múltiplos users:**")
Expand All @@ -152,6 +153,12 @@ class DailyCheckCommand(val helper: LorittaHelper) : SlashCommandDeclarationWrap
}
}

if (messageContent.length > 2_000) {
this.content = "*mensagem grande demais*"
} else {
this.content = messageContent
}

files += FileUpload.fromData(builder.toString().toByteArray(Charsets.UTF_8).inputStream(), "dailies.txt")
}
}
Expand Down Expand Up @@ -255,7 +262,7 @@ class DailyCheckCommand(val helper: LorittaHelper) : SlashCommandDeclarationWrap
}

context.reply(true) {
content = buildString {
val messageContent = buildString {
appendLine("**IDs encontrados:**")
for (userId in foundIds) {
append("- ")
Expand All @@ -274,6 +281,12 @@ class DailyCheckCommand(val helper: LorittaHelper) : SlashCommandDeclarationWrap
}
}

if (messageContent.length > 2_000) {
this.content = "*mensagem grande demais*"
} else {
this.content = messageContent
}

files += FileUpload.fromData(builder.toString().toByteArray(Charsets.UTF_8).inputStream(), "dailies.txt")
}
}
Expand Down Expand Up @@ -329,7 +342,7 @@ class DailyCheckCommand(val helper: LorittaHelper) : SlashCommandDeclarationWrap
val userEmote = idToEmotes.getOrPut(daily[Dailies.receivedById]) {
if (emotes.isEmpty())
return@getOrPut " " // Not enough emotes, bail out

val emote = emotes.random()
emotes.remove(emote)
emote
Expand Down Expand Up @@ -378,7 +391,7 @@ class DailyCheckCommand(val helper: LorittaHelper) : SlashCommandDeclarationWrap
}

context.reply(true) {
content = buildString {
val messageContent = buildString {
appendLine("**IDs encontrados:**")
for (userId in foundIds) {
append("- ")
Expand All @@ -397,6 +410,12 @@ class DailyCheckCommand(val helper: LorittaHelper) : SlashCommandDeclarationWrap
}
}

if (messageContent.length > 2_000) {
this.content = "*mensagem grande demais*"
} else {
this.content = messageContent
}

files += FileUpload.fromData(builder.toString().toByteArray(Charsets.UTF_8).inputStream(), "dailies.txt")
}
}
Expand Down

0 comments on commit a5b19fd

Please sign in to comment.