Kord-Extensions / kord-extensions

Kord extensions framework, providing commands and distinct units of functionality
https://kordex.dev
European Union Public License 1.2
113 stars 27 forks source link

Argument converters fail to read arguments with capital letters in the name #169

Open Cypher121 opened 2 years ago

Cypher121 commented 2 years ago

Description

Argument converters like stringChoice allow using a capitalized argument name for the name attribute. However when using a command with such an argument, the value is not read correctly, either using the default, if one exists, or showing an error (Invalid value for argument Choice (which accepts: text))

Versions

Latest KordEx snapshot at 1.5.5-SNAPSHOT

Code Examples

class TestExtension : Extension() {
    override val name = "test"

    override suspend fun setup() {
        publicSlashCommand(::TestArgs) {
            name = "test"
            description = "test"

            guild(TEST_SERVER_ID)

            action {
                respond {
                    content = arguments.choice
                }
            }
        }
    }

    class TestArgs : Arguments() {
        val choice by stringChoice {
            name = "Choice"
            description = "Choice"

            choices = listOf("this", "other", "that")
                .associateBy { it }
                .toMutableMap()
        }
    }
}

Suggestions

I'd suggest disallowing capitals in the name entirely: discord lowercases arg names anyway, so it's misleading to allow them. Same goes for command names as well.

boring-cyborg[bot] commented 2 years ago

Hello, and thanks for opening an issue! As this is the first time you've created an issue on this repository, we'd just like to offer you a warm welcome to the project, and the following pointers:

gdude2002 commented 2 years ago

Discord is fairly inconsistent with its support for capitalization, and I don't think a simple case check is sufficient because of i18n. It's true that this should be better telegraphed somehow, but I'm not 100% sure what the best way to do that is.