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(components): support premium buttons #1276

Merged
merged 11 commits into from
Feb 5, 2025
Merged

Conversation

shiftinv
Copy link
Member

Summary

This adds support for premium buttons via ButtonStyle.premium and ui.Button.sku_id, and deprecates InteractionResponse.require_premium1.

discord/discord-api-docs@4853fbc

Checklist

  • If code changes were made, then they have been tested
    • I have updated the documentation to reflect the changes
    • I have formatted the code properly by running pdm lint
    • I have type-checked the code by running pdm pyright
  • This PR fixes an issue
  • This PR adds something new (e.g. new method or parameters)
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

Footnotes

  1. Looks like this response type does not work at all anymore, contrary to the documentation and changelog, which claim "This will continue to function but may be eventually unsupported.". This makes it already a breaking change on Discord's end, so no point in making it even more breaking here. Still, it could honestly just be removed.

This updates the workaround added in 41618b1,
which attempts to preserve the row of url buttons. This already technically worked
for premium buttons too, but only due to a bug in that previous implementation.

Still, this remains an awful workaround. It may be easier to only update the components
directly, and leave `self.children` as is, ignoring additions/removals (which shouldn't happen here
in the first place). Alternatively, the new `id` field could also work, though it's currently still
part of that other thing and not public.
@shiftinv shiftinv added t: enhancement New feature t: api support Support of Discord API features t: deprecation Deprecation of existing features labels Jan 22, 2025
@shiftinv shiftinv added this to the disnake v2.11 milestone Jan 22, 2025
@Enegg
Copy link
Contributor

Enegg commented Jan 22, 2025

Can we please model SKU and URL buttons as distinct types 🙏

disnake/ui/button.py Show resolved Hide resolved
disnake/ui/button.py Outdated Show resolved Hide resolved
disnake/ui/button.py Show resolved Hide resolved
disnake/components.py Show resolved Hide resolved
Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com>
Signed-off-by: vi <8530778+shiftinv@users.noreply.github.com>
@Enegg
Copy link
Contributor

Enegg commented Jan 25, 2025

I suppose ActionRow.add_button should also be updated to work with SKUs

@shiftinv
Copy link
Member Author

I suppose ActionRow.add_button should also be updated to work with SKUs

yup, thanks! 0636ffe

@shiftinv shiftinv merged commit 2ab0c53 into master Feb 5, 2025
29 checks passed
@shiftinv shiftinv deleted the feature/premium-sku-button branch February 5, 2025 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: api support Support of Discord API features t: deprecation Deprecation of existing features t: enhancement New feature
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants