Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support modal interactions #15

Open
LukasDoesDev opened this issue Aug 3, 2022 · 4 comments
Open

Support modal interactions #15

LukasDoesDev opened this issue Aug 3, 2022 · 4 comments

Comments

@LukasDoesDev
Copy link

Modal support would be really convenient. A basic struct for modals would be great.

#[derive(ModalDerive)]
#[modal(title="my modal's title", custom_id="this_will_be_used_in_the_parser_too"]
struct MyModal {
    // The fields will automatically get wrapped with actionrows maybe?
    #[modal_field(custom_id="foo", label="Foo", value=1_u8, type=select_menu)]
    my_modal_field: u8,
    #[modal_field(custom_id="bar", label="Bar", max_length=20, text_input_ style=short, type=text_input)]
    my_text_input_field: String
}
@baptiste0928 baptiste0928 changed the title SUGGESTION: Modal support Support modal interactions Aug 22, 2022
@baptiste0928
Copy link
Owner

Hello! Modals are much simpler than commands, I don't think that derive macros are necessary for this (especially since it is complicated to maintain). What do you think about a method similar to CommandInputData::parse_field instead?

@LukasDoesDev
Copy link
Author

A parser is really the thing I'm looking for

@randomairborne
Copy link
Contributor

A parser is what I would be looking for too. Creating them with a macro would be nice, parsing them with a macro would be amazing.

@laralove143
Copy link
Contributor

modals work with components, why not make it so that it works with components and modals
here's a PoC:

#[derive(ComponentModel, CreateComponent)]
struct MyComponents {
    #[component(label = "just the beginning", kind = ComponentType::Button)]
    // custom_id is my_component
    my_component: Vec<String>, // values, can be anything that impl parse from String, empty for buttons etc
}

// create usage
interaction_client.create_response(.., &Response {
        ...
    }.add_component::<MyComponents>::() // provided by CreateComponent trait
)

// parse usage
MyComponents::from_components(
    ComponentInputData::from(message_component_interaction_data)
)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants