Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MessageBuilder.Limits object #959

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rest/api/rest.api
Original file line number Diff line number Diff line change
Expand Up @@ -2143,6 +2143,12 @@ public final class dev/kord/rest/builder/message/MessageBuilder$DefaultImpls {
public static fun addFile (Ldev/kord/rest/builder/message/MessageBuilder;Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile;
}

public final class dev/kord/rest/builder/message/MessageBuilder$Limits {
public static final field INSTANCE Ldev/kord/rest/builder/message/MessageBuilder$Limits;
public static final field content I
public static final field embedCount I
}

public final class dev/kord/rest/builder/message/MessageBuilderJvmKt {
public static final fun addFile (Ldev/kord/rest/builder/message/MessageBuilder;Ljava/nio/file/Path;)Ldev/kord/rest/NamedFile;
public static final fun addFile (Ldev/kord/rest/builder/message/MessageBuilder;Ljava/nio/file/Path;Lkotlin/jvm/functions/Function1;)Ldev/kord/rest/NamedFile;
Expand Down
7 changes: 7 additions & 0 deletions rest/api/rest.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,13 @@ abstract interface dev.kord.rest.builder.message/MessageBuilder { // dev.kord.re
abstract fun <set-suppressEmbeds>(kotlin/Boolean?) // dev.kord.rest.builder.message/MessageBuilder.suppressEmbeds.<set-suppressEmbeds>|<set-suppressEmbeds>(kotlin.Boolean?){}[0]

open fun addFile(kotlin/String, io.ktor.client.request.forms/ChannelProvider): dev.kord.rest/NamedFile // dev.kord.rest.builder.message/MessageBuilder.addFile|addFile(kotlin.String;io.ktor.client.request.forms.ChannelProvider){}[0]

final object Limits { // dev.kord.rest.builder.message/MessageBuilder.Limits|null[0]
final const val content // dev.kord.rest.builder.message/MessageBuilder.Limits.content|{}content[0]
final fun <get-content>(): kotlin/Int // dev.kord.rest.builder.message/MessageBuilder.Limits.content.<get-content>|<get-content>(){}[0]
final const val embedCount // dev.kord.rest.builder.message/MessageBuilder.Limits.embedCount|{}embedCount[0]
final fun <get-embedCount>(): kotlin/Int // dev.kord.rest.builder.message/MessageBuilder.Limits.embedCount.<get-embedCount>|<get-embedCount>(){}[0]
}
}

abstract interface dev.kord.rest.builder/AuditBuilder { // dev.kord.rest.builder/AuditBuilder|null[0]
Expand Down
16 changes: 14 additions & 2 deletions rest/src/commonMain/kotlin/builder/message/MessageBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import kotlin.contracts.contract
@KordDsl
public interface MessageBuilder {

/** The message contents (up to 2000 characters). */
/** The message contents. Limited to the length of [Limits.content]. */
public var content: String?

/** Up to 10 embeds (up to 6000 characters). */
/** The embeds in the message. Limited to [Limits.embedCount] embeds. */
public var embeds: MutableList<EmbedBuilder>?

/**
Expand Down Expand Up @@ -57,6 +57,18 @@ public interface MessageBuilder {
files.add(file)
return file
}

public object Limits {
/**
* The maximum length of the [MessageBuilder.content] field.
*/
public const val content: Int = 2000

/**
* The maximum amount of [MessageBuilder.embeds] in a [MessageBuilder].
*/
public const val embedCount: Int = 10
}
}

/**
Expand Down