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

feat(twilight-model)!: Implement additional select menu types #2219

Merged
merged 7 commits into from
Jul 1, 2023

Commits on Jun 12, 2023

  1. feat(twilight-model)!: Implement additional select menu types

    This patch implements the additional select menu types `user`, `role`,
    `mentionable`, and `channel`. Moreover, it moves the type-specific data
    for the existing text select menu implementation into a separate enum
    variant.
    
    The new types are implemented by "semi-flattening" the `SelectMenu`
    struct: fields common to all select menu types are implemented in the
    struct itself, and type-specific fields like the available options or
    channel types are moved into a `SelectMenuData` enum. This enum is also
    used to select a select menu's type.
    
    This approach de-duplicates the common fields while preventing users
    from accessing fields irrelevant to the current select menu type.
    
    Finally, this commit updates the documentation and existing tests to
    reflect these changes. The tests, however, might require additional
    attention in case new behaviour introduced by this commit should be
    tested as well.
    archer-321 committed Jun 12, 2023
    Configuration menu
    Copy the full SHA
    1c6ec8f View commit details
    Browse the repository at this point in the history

Commits on Jun 13, 2023

  1. refactor(twilight-model): Use unreachable! in ComponentVisitor

    This patch makes `ComponentVisitor::visit_map` use `unreachable!`
    instead of `panic!` in case a select menu type was not implemented while
    being listed in a previous match statement.
    
    Moreover, this commit sneaks in a minor formatting fix inside
    `Components` doc-comment example.
    archer-321 committed Jun 13, 2023
    Configuration menu
    Copy the full SHA
    b545e9e View commit details
    Browse the repository at this point in the history
  2. feat(twilight-model)!: Implement resolved for select menu interactions

    This commit implements the `resolved` field for
    `MessageComponentInteraction`. This field holds resolved users, roles,
    channels, or attachments for select menu interactions.
    
    Unfortunately, the new field makes it impossible to implement `Eq` and
    `Hash` for `MessageComponentInteractionData`.
    archer-321 committed Jun 13, 2023
    Configuration menu
    Copy the full SHA
    e8fffb2 View commit details
    Browse the repository at this point in the history
  3. test(twilight-model): Fix tests for InteractionDataResolved

    This commit fixes the tests testing the (de-)serialization of
    `InteractionDataResolved`. Previously, the tests were failing, as the
    type was renamed from `CommandInteractionDataResolved`.
    
    Moreover, this commit fixes the message component interaction tests by
    adding the missing `resolved` field to the expected fields in
    `message_component_interaction_data`.
    archer-321 committed Jun 13, 2023
    Configuration menu
    Copy the full SHA
    52f6e47 View commit details
    Browse the repository at this point in the history

Commits on Jun 14, 2023

  1. refactor(twilight-model)!: Un-Box SelectMenuData variants

    This commit unboxes `SelectMenuData`'s variants. They were boxed in a
    previous patch to prevent future fields from unnecessarily increasing
    the enum's memory footprint, but considering that, with the current
    structures, new fields are a breaking change already, it's OK to leave
    the variants unboxed for now and re-box as necessary.
    
    For the current code, this saves a heap allocation while only marginally
    increasing the enum's memory footprint.
    
    This change is only breaking in the context of PR twilight-rs#2219. When added to
    the commits in this PR, it doesn't add any breaking changes to the PR's
    list of breaking changes.
    archer-321 committed Jun 14, 2023
    Configuration menu
    Copy the full SHA
    c9a1a7f View commit details
    Browse the repository at this point in the history

Commits on Jun 24, 2023

  1. refactor(twilight-model)!: Fully flatten SelectMenu

    This commit removes the SelectMenuData type and embeds all
    variant-specific fields in the base struct. Moreover, it adds
    documentation indicating which fields are required variant-specific
    fields.
    
    This commit also updates the component validation module in
    `twilight-validate` by introducing a new error type for text select
    menus that don't have the necessary `options` field.
    archer-321 committed Jun 24, 2023
    Configuration menu
    Copy the full SHA
    c774adc View commit details
    Browse the repository at this point in the history

Commits on Jun 25, 2023

  1. docs(twilight-model)!: Streamline select menu documentation

    This commit streamlines the language in the `SelectMenu` and
    `SelectMenuType` documentation. In particular, it removes duplicated
    sections outlining required and optional fields. Moreover, it makes
    language describing which menu types use a specific option more in
    line with the rest of the library.
    archer-321 committed Jun 25, 2023
    Configuration menu
    Copy the full SHA
    ab68bfb View commit details
    Browse the repository at this point in the history