diff --git a/imperium-common/src/main/kotlin/com/xpdustry/imperium/common/command/annotation/Range.kt b/imperium-common/src/main/kotlin/com/xpdustry/imperium/common/command/annotation/Range.kt index 6bf23800..91f2e294 100644 --- a/imperium-common/src/main/kotlin/com/xpdustry/imperium/common/command/annotation/Range.kt +++ b/imperium-common/src/main/kotlin/com/xpdustry/imperium/common/command/annotation/Range.kt @@ -17,6 +17,9 @@ */ package com.xpdustry.imperium.common.command.annotation +// TODO +// Using AnnotationTarget.TYPE CRASHES, AND IT HAS BEEN AN ISSUE FOR 3 YEARS!! +// Could be fixed with a custom proxy via java (https://stackoverflow.com/a/13324487) @Retention(AnnotationRetention.RUNTIME) @Target(AnnotationTarget.VALUE_PARAMETER) annotation class Range(val min: String = "", val max: String = "") diff --git a/imperium-discord/src/main/kotlin/com/xpdustry/imperium/discord/command/SlashCommandRegistry.kt b/imperium-discord/src/main/kotlin/com/xpdustry/imperium/discord/command/SlashCommandRegistry.kt index 07eb3748..ff61dd06 100644 --- a/imperium-discord/src/main/kotlin/com/xpdustry/imperium/discord/command/SlashCommandRegistry.kt +++ b/imperium-discord/src/main/kotlin/com/xpdustry/imperium/discord/command/SlashCommandRegistry.kt @@ -212,7 +212,7 @@ class SlashCommandRegistry( "$function has unsupported parameter type $classifier") } - arguments += createCommandEdgeArgument(parameter.name!!, optional, classifier) + arguments += createCommandEdgeArgument(parameter, optional, classifier) } function.isAccessible = true @@ -232,14 +232,14 @@ class SlashCommandRegistry( @Suppress("UNCHECKED_CAST") private fun createCommandEdgeArgument( - name: String, + parameter: KParameter, optional: Boolean, - klass: KClass + klass: KClass, ): CommandEdge.Argument { val handler = handlers[klass] as TypeHandler? ?: throw IllegalArgumentException("Unsupported type $klass") - return CommandEdge.Argument(name, optional, klass, handler) + return CommandEdge.Argument(parameter.name!!, optional, parameter, handler) } private fun compile() {