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

[Feature] Add useful utility methods to ModalBuilder #2773

Merged

Conversation

zobweyt
Copy link
Contributor

@zobweyt zobweyt commented Sep 1, 2023

Description

This PR adds some useful utility methods to the ModalBuilder.

Now it's very easy to respond and update an existing modal in a command handler within a module like this:

await RespondWithModalAsync<MyModal>("modal_id", builder =>
{
    builder
        .WithTitle("Editing my properties…")
        .UpdateTextInput("name", "New name")
        .UpdateTextInput("timestamp", 1119191606)
        .UpdateTextInput("description", input => 
        {
            input.Style = TextInputStyle.Paragraph;
            input.Value = "New description";
        })
        .RemoveComponent("id");
});

Changes

  • Add method to get a component of type. (c73b7c0)
  • Add methods to update a component either by using a builder or by directly modifying its value. (8623a0e)
  • Add methods to remove a component or components of a certain type. (b1b5fa3)
  • Add missing row parameter to the AddTextInput wrapper. (1647b0a)
  • Update XML documentation. (a101eaa)
  • Reorder properties to follow the coding style. (ae71f17)

Co-authored-by: Misha133 <61027276+Misha-133@users.noreply.github.com>
@Misha-133 Misha-133 merged commit 8591de7 into discord-net:dev Sep 2, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants