diff --git a/annotation-processor/src/main/kotlin/com/kotlindiscord/kord/extensions/modules/annotations/converters/ConverterProcessor.kt b/annotation-processor/src/main/kotlin/com/kotlindiscord/kord/extensions/modules/annotations/converters/ConverterProcessor.kt index 67cf5a6730..e9e403beef 100644 --- a/annotation-processor/src/main/kotlin/com/kotlindiscord/kord/extensions/modules/annotations/converters/ConverterProcessor.kt +++ b/annotation-processor/src/main/kotlin/com/kotlindiscord/kord/extensions/modules/annotations/converters/ConverterProcessor.kt @@ -154,24 +154,26 @@ public class ConverterProcessor( val outputText = buildString { append( """ - @file:OptIn( - KordPreview::class, - ConverterToDefaulting::class, - ConverterToMulti::class, - ConverterToOptional::class - ) - - package ${classDeclaration.packageName.asString()} - - // Original converter class, for safety - import ${classDeclaration.qualifiedName!!.asString()} - - // Imports that all converters need - import com.kotlindiscord.kord.extensions.InvalidArgumentException - import com.kotlindiscord.kord.extensions.commands.Arguments - import com.kotlindiscord.kord.extensions.commands.converters.* - import com.kotlindiscord.kord.extensions.commands.converters.builders.* - import dev.kord.common.annotation.KordPreview + @file:OptIn( + KordPreview::class, + ConverterToDefaulting::class, + ConverterToMulti::class, + ConverterToOptional::class, + UnexpectedFunctionBehaviour::class, + ) + + package ${classDeclaration.packageName.asString()} + + // Original converter class, for safety + import ${classDeclaration.qualifiedName!!.asString()} + + // Imports that all converters need + import com.kotlindiscord.kord.extensions.InvalidArgumentException + import com.kotlindiscord.kord.extensions.annotations.UnexpectedFunctionBehaviour + import com.kotlindiscord.kord.extensions.commands.Arguments + import com.kotlindiscord.kord.extensions.commands.converters.* + import com.kotlindiscord.kord.extensions.commands.converters.builders.* + import dev.kord.common.annotation.KordPreview """.trimIndent() ) diff --git a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/annotations/UnexpectedBehaviour.kt b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/annotations/UnexpectedFunctionBehaviour.kt similarity index 68% rename from kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/annotations/UnexpectedBehaviour.kt rename to kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/annotations/UnexpectedFunctionBehaviour.kt index 5772285024..3991931ff0 100644 --- a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/annotations/UnexpectedBehaviour.kt +++ b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/annotations/UnexpectedFunctionBehaviour.kt @@ -8,9 +8,9 @@ package com.kotlindiscord.kord.extensions.annotations /** Marks a function that may result in unexpected behaviour, and ask the developer to check the docs. **/ @RequiresOptIn( - message = "Calling this function may result in unexpected behaviour. Please ensure you read its documentation " + - "comment before continuing.", + message = "Calling or overriding this function may result in unexpected behaviour. Please ensure you read its " + + "documentation comment before continuing.", level = RequiresOptIn.Level.WARNING ) @Target(AnnotationTarget.FUNCTION) -public annotation class UnexpectedBehaviour +public annotation class UnexpectedFunctionBehaviour diff --git a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/commands/Arguments.kt b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/commands/Arguments.kt index 1b10634ebb..1108680282 100644 --- a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/commands/Arguments.kt +++ b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/commands/Arguments.kt @@ -6,6 +6,7 @@ package com.kotlindiscord.kord.extensions.commands +import com.kotlindiscord.kord.extensions.annotations.UnexpectedFunctionBehaviour import com.kotlindiscord.kord.extensions.commands.converters.* /** @@ -42,6 +43,7 @@ public open class Arguments { * * @return Argument converter to use as a delegate. */ + @UnexpectedFunctionBehaviour public fun arg( displayName: String, description: String, @@ -63,6 +65,7 @@ public open class Arguments { * * @return Argument converter to use as a delegate. */ + @UnexpectedFunctionBehaviour public fun arg( displayName: String, description: String, @@ -84,6 +87,7 @@ public open class Arguments { * * @return Argument converter to use as a delegate. */ + @UnexpectedFunctionBehaviour public fun arg( displayName: String, description: String, @@ -105,6 +109,7 @@ public open class Arguments { * * @return Argument converter to use as a delegate. */ + @UnexpectedFunctionBehaviour public fun arg( displayName: String, description: String, @@ -126,6 +131,7 @@ public open class Arguments { * * @return Argument converter to use as a delegate. */ + @UnexpectedFunctionBehaviour public fun arg( displayName: String, description: String, @@ -147,6 +153,7 @@ public open class Arguments { * * @return Argument converter to use as a delegate. */ + @UnexpectedFunctionBehaviour public fun arg( displayName: String, description: String, @@ -168,6 +175,7 @@ public open class Arguments { * * @return Argument converter to use as a delegate. */ + @UnexpectedFunctionBehaviour public fun arg( displayName: String, description: String, diff --git a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/types/EphemeralInteractionContext.kt b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/types/EphemeralInteractionContext.kt index d3de989883..e3cf4429fb 100644 --- a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/types/EphemeralInteractionContext.kt +++ b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/types/EphemeralInteractionContext.kt @@ -7,7 +7,7 @@ package com.kotlindiscord.kord.extensions.types import com.kotlindiscord.kord.extensions.annotations.AlwaysPublicResponse -import com.kotlindiscord.kord.extensions.annotations.UnexpectedBehaviour +import com.kotlindiscord.kord.extensions.annotations.UnexpectedFunctionBehaviour import com.kotlindiscord.kord.extensions.pagination.EphemeralResponsePaginator import com.kotlindiscord.kord.extensions.pagination.PublicFollowUpPaginator import com.kotlindiscord.kord.extensions.pagination.builders.PaginatorBuilder @@ -38,7 +38,7 @@ public interface EphemeralInteractionContext : InteractionContext< builder: suspend FollowupMessageCreateBuilder.() -> Unit, ): EphemeralFollowupMessage = interactionResponse.createEphemeralFollowup { builder() } - @UnexpectedBehaviour + @UnexpectedFunctionBehaviour public override suspend fun respondOpposite( builder: suspend FollowupMessageCreateBuilder.() -> Unit, ): PublicFollowupMessage = interactionResponse.createPublicFollowup { builder() } diff --git a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/types/InteractionContext.kt b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/types/InteractionContext.kt index 45568a2718..ad092eeb36 100644 --- a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/types/InteractionContext.kt +++ b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/types/InteractionContext.kt @@ -9,7 +9,7 @@ package com.kotlindiscord.kord.extensions.types import com.kotlindiscord.kord.extensions.annotations.AlwaysPublicResponse -import com.kotlindiscord.kord.extensions.annotations.UnexpectedBehaviour +import com.kotlindiscord.kord.extensions.annotations.UnexpectedFunctionBehaviour import com.kotlindiscord.kord.extensions.pagination.BaseButtonPaginator import com.kotlindiscord.kord.extensions.pagination.builders.PaginatorBuilder import dev.kord.core.behavior.interaction.response.InteractionResponseBehavior @@ -79,7 +79,7 @@ public interface InteractionContext< * While Discord's API allows you to do this, it will rarely do what you'd expect. * Only use this if you're sure it'll do what you want, and test thoroughly. */ - @UnexpectedBehaviour + @UnexpectedFunctionBehaviour public suspend fun respondOpposite( builder: suspend FollowupMessageCreateBuilder.() -> Unit, ): OppositeFollowupType diff --git a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/types/PublicInteractionContext.kt b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/types/PublicInteractionContext.kt index b1d20b1865..752ce61fe4 100644 --- a/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/types/PublicInteractionContext.kt +++ b/kord-extensions/src/main/kotlin/com/kotlindiscord/kord/extensions/types/PublicInteractionContext.kt @@ -7,7 +7,7 @@ package com.kotlindiscord.kord.extensions.types import com.kotlindiscord.kord.extensions.annotations.AlwaysPublicResponse -import com.kotlindiscord.kord.extensions.annotations.UnexpectedBehaviour +import com.kotlindiscord.kord.extensions.annotations.UnexpectedFunctionBehaviour import com.kotlindiscord.kord.extensions.pagination.PublicFollowUpPaginator import com.kotlindiscord.kord.extensions.pagination.PublicResponsePaginator import com.kotlindiscord.kord.extensions.pagination.builders.PaginatorBuilder @@ -37,7 +37,7 @@ public interface PublicInteractionContext : InteractionContext< builder: suspend FollowupMessageCreateBuilder.() -> Unit, ): PublicFollowupMessage = interactionResponse.createPublicFollowup { builder() } - @UnexpectedBehaviour + @UnexpectedFunctionBehaviour public override suspend fun respondOpposite( builder: suspend FollowupMessageCreateBuilder.() -> Unit, ): EphemeralFollowupMessage = interactionResponse.createEphemeralFollowup { builder() } diff --git a/modules/unsafe/src/main/kotlin/com/kotlindiscord/kord/extensions/modules/unsafe/converters/UnionConverter.kt b/modules/unsafe/src/main/kotlin/com/kotlindiscord/kord/extensions/modules/unsafe/converters/UnionConverter.kt index 2dce822060..99bf159e02 100644 --- a/modules/unsafe/src/main/kotlin/com/kotlindiscord/kord/extensions/modules/unsafe/converters/UnionConverter.kt +++ b/modules/unsafe/src/main/kotlin/com/kotlindiscord/kord/extensions/modules/unsafe/converters/UnionConverter.kt @@ -5,13 +5,15 @@ */ @file:OptIn( - ConverterToOptional::class + ConverterToOptional::class, + UnexpectedFunctionBehaviour::class ) @file:Suppress("StringLiteralDuplication") package com.kotlindiscord.kord.extensions.modules.unsafe.converters import com.kotlindiscord.kord.extensions.DiscordRelayedException +import com.kotlindiscord.kord.extensions.annotations.UnexpectedFunctionBehaviour import com.kotlindiscord.kord.extensions.commands.Argument import com.kotlindiscord.kord.extensions.commands.Arguments import com.kotlindiscord.kord.extensions.commands.CommandContext