Skip to content

Commit

Permalink
Merge branch 'main' into feat/entitlements
Browse files Browse the repository at this point in the history
  • Loading branch information
lukellmann committed Sep 10, 2024
2 parents 7c47744 + 4f6712f commit 4753b78
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 49 deletions.
16 changes: 11 additions & 5 deletions buildSrc/src/main/kotlin/Compiler.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import org.gradle.api.NamedDomainObjectSet
import org.gradle.kotlin.dsl.assign
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet

val kordOptIns = listOf(
Expand All @@ -12,16 +14,20 @@ val kordOptIns = listOf(
"dev.kord.common.annotation.KordVoice",
)

object Jvm {
const val target = 8
}

fun KotlinCommonCompilerOptions.applyKordCompilerOptions() {
internal fun KotlinCommonCompilerOptions.applyKordCommonCompilerOptions() {
allWarningsAsErrors = true
progressiveMode = true
freeCompilerArgs.add("-Xexpect-actual-classes")
}

internal const val KORD_JVM_TARGET = 8

internal fun KotlinJvmCompilerOptions.applyKordJvmCompilerOptions() {
applyKordCommonCompilerOptions()
jvmTarget = JVM_1_8
freeCompilerArgs.add("-Xjdk-release=1.8")
}

internal fun NamedDomainObjectSet<KotlinSourceSet>.applyKordTestOptIns() {
named { it.contains("test", ignoreCase = true) }.configureEach {
// allow `ExperimentalCoroutinesApi` for `TestScope.currentTime`
Expand Down
9 changes: 7 additions & 2 deletions buildSrc/src/main/kotlin/kord-internal-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ repositories {
}

kotlin {
jvmToolchain(Jvm.target)
compilerOptions {
applyKordCompilerOptions()
applyKordJvmCompilerOptions()
}
}

tasks {
withType<JavaCompile>().configureEach {
options.release = KORD_JVM_TARGET
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ repositories {
mavenCentral()
}

@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
jvm()
compilerOptions {
applyKordCommonCompilerOptions()
}

jvm {
compilerOptions {
applyKordJvmCompilerOptions()
}
}
js {
nodejs()
useCommonJs()
}
jvmToolchain(Jvm.target)

@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
applyKordCompilerOptions()
}
}

tasks {
Expand Down
9 changes: 5 additions & 4 deletions buildSrc/src/main/kotlin/kord-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ apiValidation {

kotlin {
explicitApi()

jvmToolchain(Jvm.target)

compilerOptions {
applyKordCompilerOptions()
applyKordJvmCompilerOptions()
optIn.addAll(kordOptIns)
}

Expand All @@ -45,6 +42,10 @@ tasks {
withType<AbstractDokkaLeafTask>().configureEach {
applyKordDokkaOptions()
}

withType<JavaCompile>().configureEach {
options.release = KORD_JVM_TARGET
}
}

publishing {
Expand Down
18 changes: 10 additions & 8 deletions buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,19 @@ apiValidation {
applyKordBCVOptions()
}

@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
explicitApi()
compilerOptions {
applyKordCommonCompilerOptions()
optIn.addAll(kordOptIns)
}

jvm()
jvm {
compilerOptions {
applyKordJvmCompilerOptions()
}
}
js {
nodejs {
testTask {
Expand All @@ -39,13 +48,6 @@ kotlin {
}
useCommonJs()
}
jvmToolchain(Jvm.target)

@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
applyKordCompilerOptions()
optIn.addAll(kordOptIns)
}

applyDefaultHierarchyTemplate()

Expand Down
4 changes: 1 addition & 3 deletions rest/api/rest.api
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ public final class dev/kord/rest/builder/automoderation/KeywordAutoModerationRul

public final class dev/kord/rest/builder/automoderation/KeywordAutoModerationRuleCreateBuilder : dev/kord/rest/builder/automoderation/AutoModerationRuleCreateBuilder, dev/kord/rest/builder/automoderation/KeywordAutoModerationRuleBuilder {
public fun <init> (Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;)V
public synthetic fun buildTriggerMetadata ()Ldev/kord/common/entity/optional/Optional;
public fun getAllowedKeywords ()Ljava/util/List;
public fun getKeywords ()Ljava/util/List;
public fun getRegexPatterns ()Ljava/util/List;
Expand All @@ -274,6 +273,7 @@ public abstract interface class dev/kord/rest/builder/automoderation/KeywordPres
public abstract fun assignPresets (Ljava/util/List;)V
public abstract fun getPresets ()Ljava/util/List;
public abstract fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType$KeywordPreset;
public abstract fun setPresets (Ljava/util/List;)V
}

public final class dev/kord/rest/builder/automoderation/KeywordPresetAutoModerationRuleBuilder$DefaultImpls {
Expand All @@ -283,7 +283,6 @@ public final class dev/kord/rest/builder/automoderation/KeywordPresetAutoModerat
public final class dev/kord/rest/builder/automoderation/KeywordPresetAutoModerationRuleCreateBuilder : dev/kord/rest/builder/automoderation/AutoModerationRuleCreateBuilder, dev/kord/rest/builder/automoderation/KeywordPresetAutoModerationRuleBuilder {
public fun <init> (Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;)V
public fun assignPresets (Ljava/util/List;)V
public synthetic fun buildTriggerMetadata ()Ldev/kord/common/entity/optional/Optional;
public fun getAllowedKeywords ()Ljava/util/List;
public fun getPresets ()Ljava/util/List;
public fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType$KeywordPreset;
Expand Down Expand Up @@ -317,7 +316,6 @@ public final class dev/kord/rest/builder/automoderation/MentionSpamAutoModeratio

public final class dev/kord/rest/builder/automoderation/MentionSpamAutoModerationRuleCreateBuilder : dev/kord/rest/builder/automoderation/AutoModerationRuleCreateBuilder, dev/kord/rest/builder/automoderation/MentionSpamAutoModerationRuleBuilder {
public fun <init> (Ljava/lang/String;Ldev/kord/common/entity/AutoModerationRuleEventType;)V
public synthetic fun buildTriggerMetadata ()Ldev/kord/common/entity/optional/Optional;
public fun getMentionLimit ()Ljava/lang/Integer;
public fun getMentionRaidProtectionEnabled ()Ljava/lang/Boolean;
public fun getTriggerType ()Ldev/kord/common/entity/AutoModerationRuleTriggerType$MentionSpam;
Expand Down
10 changes: 6 additions & 4 deletions rest/api/rest.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,13 @@ sealed interface dev.kord.rest.builder.automoderation/KeywordAutoModerationRuleB
}

sealed interface dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder : dev.kord.rest.builder.automoderation/AllowedKeywordsAutoModerationRuleBuilder { // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder|null[0]
abstract val presets // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder.presets|{}presets[0]
abstract fun <get-presets>(): kotlin.collections/MutableList<dev.kord.common.entity/AutoModerationRuleKeywordPresetType>? // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder.presets.<get-presets>|<get-presets>(){}[0]
open val triggerType // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder.triggerType|{}triggerType[0]
open fun <get-triggerType>(): dev.kord.common.entity/AutoModerationRuleTriggerType.KeywordPreset // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder.triggerType.<get-triggerType>|<get-triggerType>(){}[0]

abstract var presets // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder.presets|{}presets[0]
abstract fun <get-presets>(): kotlin.collections/MutableList<dev.kord.common.entity/AutoModerationRuleKeywordPresetType>? // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder.presets.<get-presets>|<get-presets>(){}[0]
abstract fun <set-presets>(kotlin.collections/MutableList<dev.kord.common.entity/AutoModerationRuleKeywordPresetType>?) // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder.presets.<set-presets>|<set-presets>(kotlin.collections.MutableList<dev.kord.common.entity.AutoModerationRuleKeywordPresetType>?){}[0]

abstract fun assignPresets(kotlin.collections/MutableList<dev.kord.common.entity/AutoModerationRuleKeywordPresetType>) // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleBuilder.assignPresets|assignPresets(kotlin.collections.MutableList<dev.kord.common.entity.AutoModerationRuleKeywordPresetType>){}[0]
}

Expand Down Expand Up @@ -769,8 +771,8 @@ final class dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRule
final fun <get-allowedKeywords>(): kotlin.collections/MutableList<kotlin/String>? // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleCreateBuilder.allowedKeywords.<get-allowedKeywords>|<get-allowedKeywords>(){}[0]
final fun <set-allowedKeywords>(kotlin.collections/MutableList<kotlin/String>?) // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleCreateBuilder.allowedKeywords.<set-allowedKeywords>|<set-allowedKeywords>(kotlin.collections.MutableList<kotlin.String>?){}[0]
final var presets // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleCreateBuilder.presets|{}presets[0]
final fun <get-presets>(): kotlin.collections/MutableList<dev.kord.common.entity/AutoModerationRuleKeywordPresetType> // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleCreateBuilder.presets.<get-presets>|<get-presets>(){}[0]
final fun <set-presets>(kotlin.collections/MutableList<dev.kord.common.entity/AutoModerationRuleKeywordPresetType>) // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleCreateBuilder.presets.<set-presets>|<set-presets>(kotlin.collections.MutableList<dev.kord.common.entity.AutoModerationRuleKeywordPresetType>){}[0]
final fun <get-presets>(): kotlin.collections/MutableList<dev.kord.common.entity/AutoModerationRuleKeywordPresetType>? // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleCreateBuilder.presets.<get-presets>|<get-presets>(){}[0]
final fun <set-presets>(kotlin.collections/MutableList<dev.kord.common.entity/AutoModerationRuleKeywordPresetType>?) // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleCreateBuilder.presets.<set-presets>|<set-presets>(kotlin.collections.MutableList<dev.kord.common.entity.AutoModerationRuleKeywordPresetType>?){}[0]

final fun assignPresets(kotlin.collections/MutableList<dev.kord.common.entity/AutoModerationRuleKeywordPresetType>) // dev.kord.rest.builder.automoderation/KeywordPresetAutoModerationRuleCreateBuilder.assignPresets|assignPresets(kotlin.collections.MutableList<dev.kord.common.entity.AutoModerationRuleKeywordPresetType>){}[0]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,24 @@ public sealed interface KeywordPresetAutoModerationRuleBuilder : AllowedKeywords
override val triggerType: KeywordPreset get() = KeywordPreset

/** The internally pre-defined wordsets which will be searched for in content. */
public val presets: MutableList<AutoModerationRuleKeywordPresetType>?
public var presets: MutableList<AutoModerationRuleKeywordPresetType>?

/**
* Use this to set [presets][KeywordPresetAutoModerationRuleBuilder.presets] for
* [KeywordPresetAutoModerationRuleBuilder].
*/
@Deprecated(
"This can be replaced with 'presets', it is now a 'var'. The deprecation level will be raised to ERROR in " +
"0.16.0, to HIDDEN in 0.17.0, and this declaration will be removed in 0.18.0.",
ReplaceWith("this.run { [email protected] = presets }", imports = ["kotlin.run"]),
DeprecationLevel.WARNING,
)
public fun assignPresets(presets: MutableList<AutoModerationRuleKeywordPresetType>)
}

/** Add a [preset] to [presets][KeywordPresetAutoModerationRuleBuilder.presets]. */
public fun KeywordPresetAutoModerationRuleBuilder.preset(preset: AutoModerationRuleKeywordPresetType) {
presets?.add(preset) ?: assignPresets(mutableListOf(preset))
presets?.add(preset) ?: run { presets = mutableListOf(preset) }
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public class KeywordAutoModerationRuleCreateBuilder(
private var _allowedKeywords: Optional<MutableList<String>> = Optional.Missing()
override var allowedKeywords: MutableList<String>? by ::_allowedKeywords.delegate()

// one of keywords or regexPatterns is required, don't bother to send missing trigger metadata if both are missing
override fun buildTriggerMetadata(): Optional.Value<DiscordAutoModerationRuleTriggerMetadata> =
// triggerMetadata is required for Keyword rules
override fun buildTriggerMetadata(): Optional<DiscordAutoModerationRuleTriggerMetadata> =
DiscordAutoModerationRuleTriggerMetadata(
keywordFilter = _keywords.mapCopy(),
regexPatterns = _regexPatterns.mapCopy(),
Expand All @@ -97,19 +97,27 @@ public class KeywordPresetAutoModerationRuleCreateBuilder(
eventType: AutoModerationRuleEventType,
) : AutoModerationRuleCreateBuilder(name, eventType), KeywordPresetAutoModerationRuleBuilder {

override var presets: MutableList<AutoModerationRuleKeywordPresetType> = mutableListOf()
private var _presets: Optional<MutableList<AutoModerationRuleKeywordPresetType>> = Optional.Missing()
override var presets: MutableList<AutoModerationRuleKeywordPresetType>? by ::_presets.delegate()

/** @suppress Use `this.presets = presets` instead. */
@Deprecated(
"Use 'this.presets = presets' instead. The deprecation level will be raised to ERROR in 0.16.0, to HIDDEN in " +
"0.17.0, and this declaration will be removed in 0.18.0.",
ReplaceWith("this.run { [email protected] = presets }", imports = ["kotlin.run"]),
DeprecationLevel.WARNING,
)
override fun assignPresets(presets: MutableList<AutoModerationRuleKeywordPresetType>) {
this.presets = presets
}

private var _allowedKeywords: Optional<MutableList<String>> = Optional.Missing()
override var allowedKeywords: MutableList<String>? by ::_allowedKeywords.delegate()

override fun buildTriggerMetadata(): Optional.Value<DiscordAutoModerationRuleTriggerMetadata> =
// triggerMetadata is required for KeywordPreset rules
override fun buildTriggerMetadata(): Optional<DiscordAutoModerationRuleTriggerMetadata> =
DiscordAutoModerationRuleTriggerMetadata(
presets = presets.toList().optional(),
presets = _presets.mapCopy(),
allowList = _allowedKeywords.mapCopy(),
).optional()
}
Expand All @@ -127,9 +135,8 @@ public class MentionSpamAutoModerationRuleCreateBuilder(
private var _mentionRaidProtectionEnabled: OptionalBoolean = OptionalBoolean.Missing
override var mentionRaidProtectionEnabled: Boolean? by ::_mentionRaidProtectionEnabled.delegate()

// one of mentionTotalLimit or mentionRaidProtectionEnabled is required, don't bother to send missing trigger
// metadata if both are missing
override fun buildTriggerMetadata(): Optional.Value<DiscordAutoModerationRuleTriggerMetadata> =
// triggerMetadata is required for MentionSpam rules
override fun buildTriggerMetadata(): Optional<DiscordAutoModerationRuleTriggerMetadata> =
DiscordAutoModerationRuleTriggerMetadata(
mentionTotalLimit = _mentionLimit,
mentionRaidProtectionEnabled = _mentionRaidProtectionEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class KeywordAutoModerationRuleModifyBuilder :
}

/** A [SpamAutoModerationRuleBuilder] for building [AutoModerationRuleModifyRequest]s. */
@Suppress("CanSealedSubClassBeObject") // has state in super class
@Suppress("CanSealedSubClassBeObject") // superclass is mutable
@KordDsl
public class SpamAutoModerationRuleModifyBuilder :
AutoModerationRuleModifyBuilder(),
Expand All @@ -119,6 +119,12 @@ public class KeywordPresetAutoModerationRuleModifyBuilder :
override var presets: MutableList<AutoModerationRuleKeywordPresetType>? by ::_presets.delegate()

/** @suppress Use `this.presets = presets` instead. */
@Deprecated(
"Use 'this.presets = presets' instead. The deprecation level will be raised to ERROR in 0.16.0, to HIDDEN in " +
"0.17.0, and this declaration will be removed in 0.18.0.",
ReplaceWith("this.run { [email protected] = presets }", imports = ["kotlin.run"]),
DeprecationLevel.WARNING,
)
override fun assignPresets(presets: MutableList<AutoModerationRuleKeywordPresetType>) {
this.presets = presets
}
Expand Down
5 changes: 0 additions & 5 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
plugins {
// https://github.com/gradle/foojay-toolchains
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}

rootProject.name = "kord"

include(
Expand Down

0 comments on commit 4753b78

Please sign in to comment.