baptiste0928 / twilight-interactions

Macros and utilities to work with Discord Interactions using twilight.
ISC License
37 stars 7 forks source link

Inadequate `CreateCommand` & `CommandModel`'s `command` Attribute Parameter Validation #21

Closed fdnt7 closed 1 year ago

fdnt7 commented 1 year ago

Steps to Reproduce

  1. Create a command struct like so:
    ...
    #[derive(CreateCommand, CommandModel)]
    #[command(name = "foo", desc = "bar")]
    pub struct Foo {
    #[command(
        // ...
    )]
    channel: Option<InteractionChannel>,
    }
    ...
  2. At the commented line, add any parameter that's a proper substring of any of the valid parameters (ex. auto of autocomplete, channel of channel_types):
    ...
    #[command(
        "channel" = "seemingly any literal goes here" // where should've been "channel_types"
    )]
    ...
  3. Compile the following snippet in an appropriate namespace.

Expected Behaviour

The macros should throw a compile time error regarding invalid parameters in the command attribute of the CreateCommand and CommandModel macros.

Actual Behaviour

There are no errors being thrown during compilation time, and the invalid parameters are silently ignored in runtime.

Additional Info

twilight-interactions Version: v0.15.0

baptiste0928 commented 1 year ago

Fixed in #22, will be released on crates.io later today. Thanks for reporting the bug!