Skip to content

[Bug]: Command with Option optional parameter won't register correctly #217

@Rutherther

Description

@Rutherther

Description

I've noticed an issue when I wanted to create a command that has a required parameter as well as Option parameter that is optional. Remora will put the optional parameter as a first one (I suspect this is because Remora.Commands just puts Option parameters as first for easier handling) and that creates a problem when registering it as a slash command.

Steps to Reproduce

A command such as this will fail to register

[Command("echo")]
[Description("Send a message")]
public Task<Result> HandleEchoAsync
(
    string message,
    [Option('c', "channel")] Snowflake? channel = null
);

Expected Behavior

Registers the slash command correctly.

Current Behavior

Puts the Option as first parameter and results in APPLICATION_COMMAND_OPTIONS_REQUIRED_INVALID Required options must be placed before non-required options error.

Library / Runtime Information

Remora.Command v10.0.1, Remora.Discord.Commands v25.1.0
.NET 6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions