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

Implement select menus #339

Merged
merged 6 commits into from
Jul 3, 2021
Merged

Implement select menus #339

merged 6 commits into from
Jul 3, 2021

Conversation

BartArys
Copy link
Contributor

@BartArys BartArys commented Jul 3, 2021

This PR adds support for select menus. Component and ComponentInteraction were broken to add support for them.

@BartArys BartArys requested a review from HopeBaron July 3, 2021 14:08
set(value) {
field = value
if (value > maximumValues) {
maximumValues = value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we check here instead of throwing

Copy link
Contributor Author

@BartArys BartArys Jul 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For one we generally don't throw in builders. I thought it'd be more intuitive that something like this would work:

selectMenu(id) {
    minValues = 2
    
   option("a", "key.a")
   option("b", "key.b")
   option("c", "key.c")
   option("d", "key.d")
}

If you think that min and max values should always be set instead when raising the minimum above 1 then I'll remove the behaviour.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly, it is kinda hard to know what would be the best approach, I mean, the request would still be valid
using an IntRange is another possible solution, and finally an exception

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds to me like an IntRange would be safe to use. We take the min value for our min_value and likewise for max. it also ensure that one is equal or less than the others. allows combos like 1..3, 1..1, 0..0, 2.downTo 5 etc..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I'll apply the suggestion

@HopeBaron HopeBaron merged commit f0a772f into 0.7.x Jul 3, 2021
HopeBaron added a commit that referenced this pull request Jul 8, 2021
* Add a cache aware rest entity supplier (#338)

* add a cahe aware rest supplier/strategy

* abstract the new flow creation for storeAndEmit

* apply suggestions

* Reduce the number of iterations

rename storeAndEmit to storeOnEach

* update changelog

* Fix master gateway average ping conversion (#337)

* Change field visibility and single-expression return syntax (#335)

* changed the visibility for the name, descript.. and type field, changed the toRequest functions to single expression-styled returns

* remade .name and .description to public upon request, kept .type protected

* remade .type into read only (val)

* Implement select menus (#339)

* Add select menu json representation

* Add select menu builders

* add serialization tests for select menu interactions

* Add core implementation of select menus

* Update ButtonComponent docs

* Make SelectMenu min/max values a range

* Fix getGuildBanOrNull recursion (#341)

Fixes the self call in getGuildBanOrNull by delegating the call to the supplier instead

* Make UpdateMessageInteractionResponseCreateBuilder fields nullable (#340)

Makes the fields in the builder and request nullable where appropriate for updating a message

* improve readme

* api dump

* add breaking changes to changelog

* mention the type visibility change

[ci skip]

Co-authored-by: Bart Arys <[email protected]>
Co-authored-by: Noak Palander <[email protected]>
@HopeBaron HopeBaron deleted the feature/select-menu branch October 7, 2021 09:53
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

Successfully merging this pull request may close these issues.

2 participants