Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Summary
This is my attempt at adding support for the new components that Discord plans to release in the distant future. This introduces the ability to have components besides action rows as top-level components, as well as the ability to nest action rows within other top-level components. Additionally, this PR now includes the
Labelcomponent that will be coming to modals along with the ability to haveTextDisplaycomponents in modals. Some potential points to discuss:has_componentsadmittedly isn't the best name for setting theIS_COMPONENTS_V2 (1 << 15)flag.Added
Builders for new components:
Webhooks::View::TextDisplayBuilderWebhooks::View::SeperatorBuilderWebhooks::View::FileBuilderWebhooks::View::MediaGalleryBuilderWebhooks::View::SectionBuilderWebhooks::View::ContainerBuilderWebhooks::Modal::LabelBuilderTop-level methods for new components:
Webhooks::View#text_displayWebhooks::View#seperatorWebhooks::View#fileWebhooks::View#media_galleryWebhooks::View#sectionWebhooks::View#containerWebhooks::Modal#text_displayWebhooks::Modal#labelData classes for serializing incoming components:
Components::TextDisplayComponents::SeperatorComponents::FileComponents::MediaGalleryComponents::SectionComponents::ContainerComponents::LabelComponents::FileUploadhas_componentsKWARG for interaction methods which sets theIS_COMPONENTS_V2 (1 << 15)flag.Channel#send_message!(**arguments)Same assend_messagebut with KWARGS and yielded builders.Changed
There are a couple of internal changes made to
Webhooks::Viewin order to make the new components possible. (Don't worry, full backwards compatibility has been maintained.)Removal of
@rows. Since action rows are no longer the only top-level components, it didn't make sense to have two separate instance variables since it would end up requiring some needless concatenation. E.g.In its place, I've replaced it with
@componentsas a way to store all top-level components. This required the removal of theattr_reader :rowsas well. It was replaced with:Fixed
Previously, when passing in an emoji object to
RowBuilder#buttonandSelectMenuBuilder#option, it would yield the following error:As stated in the error, this is because
#to_hwasn't defined anywhere for the emoji object. I've went ahead and defined this method.