Skip to content

Commit

Permalink
records: fix truncation compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lokka30 committed Oct 23, 2024
1 parent 528e116 commit 99b0c00
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package space.lachy.lachsbot.database.mongo.collection

import net.dv8tion.jda.api.EmbedBuilder
import net.dv8tion.jda.api.entities.MessageEmbed.VALUE_MAX_LENGTH
import org.bson.BsonDateTime
import org.bson.codecs.pojo.annotations.BsonId
import org.bson.codecs.pojo.annotations.BsonProperty
Expand Down Expand Up @@ -57,7 +58,7 @@ data class RecordMessageDelete(
return EmbedBuilder()
.setTitle("Message Deleted")
.setDescription("Discord's API does not advise who caused this, use Audit Log to check.")
.addField("Last Known Message Raw", messageRawLastKnown?.truncate() ?: "N/A", false)
.addField("Last Known Message Raw", messageRawLastKnown?.truncate(VALUE_MAX_LENGTH) ?: "N/A", false)
.addField("Message ID", "$messageId", true)
.addField("Timestamp Epoch", "${timestampEpoch.value}", true)
.addField("Timestamp FMT", "${Date(timestampEpoch.value)}", true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package space.lachy.lachsbot.database.mongo.collection

import net.dv8tion.jda.api.EmbedBuilder
import net.dv8tion.jda.api.entities.MessageEmbed.VALUE_MAX_LENGTH
import org.bson.BsonDateTime
import org.bson.codecs.pojo.annotations.BsonId
import org.bson.codecs.pojo.annotations.BsonProperty
Expand Down Expand Up @@ -66,8 +67,8 @@ data class RecordMessageUpdate(
fun toEmbedBuilder(): EmbedBuilder {
val builder = EmbedBuilder()
.setTitle("Message Updated")
.addField("New Message Raw", messageRawNew.truncate(), false)
.addField("Old Message Raw Last Known", messageRawLastKnown?.truncate() ?: "N/A", false)
.addField("New Message Raw", messageRawNew.truncate(VALUE_MAX_LENGTH), false)
.addField("Old Message Raw Last Known", messageRawLastKnown?.truncate(VALUE_MAX_LENGTH) ?: "N/A", false)
.addField("Message ID", "$messageId", true)
.addField("Timestamp Epoch", "${timestampEpoch.value}", true)
.addField("Timestamp FMT", "${Date(timestampEpoch.value)}", true)
Expand All @@ -82,7 +83,7 @@ data class RecordMessageUpdate(
.addField("Author Username", authorUsername, true)
.addField("Author Effective Name", authorEffectiveName, true)
.addField("Author Tag", "<@${authorId}>", true)
.addField("Jump URL", jumpUrl.truncate(), true)
.addField("Jump URL", jumpUrl.truncate(VALUE_MAX_LENGTH), true)
.setFooter("${javaClass.simpleName} - ID#$id")
.setColor(Color.LIGHT_GRAY)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.mongodb.client.model.Sorts
import kotlinx.coroutines.flow.firstOrNull
import net.dv8tion.jda.api.EmbedBuilder
import net.dv8tion.jda.api.entities.Message
import net.dv8tion.jda.api.entities.MessageEmbed.VALUE_MAX_LENGTH
import org.bson.BsonDateTime
import org.bson.BsonInt64
import space.lachy.lachsbot.database.mongo.Mongo
Expand Down Expand Up @@ -83,7 +84,7 @@ object RecordListenerManager {
for(att in attachments) {
builder.addField(
"Attachment ${i}",
"Name: '${att.name}'; Extension: '${att.extension}'; URL: '${att.url}'".truncate(),
"Name: '${att.name}'; Extension: '${att.extension}'; URL: '${att.url}'".truncate(VALUE_MAX_LENGTH),
false
)

Expand Down

0 comments on commit 99b0c00

Please sign in to comment.