Skip to content

[FEAT] Support for Discord Components V2 #1766

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

Open
1 task done
feelixs opened this issue Apr 22, 2025 · 3 comments
Open
1 task done

[FEAT] Support for Discord Components V2 #1766

feelixs opened this issue Apr 22, 2025 · 3 comments

Comments

@feelixs
Copy link

feelixs commented Apr 22, 2025

Problem Description

Discord just released their updated components API https://discord.com/developers/docs/change-log

Note from discord in their change log:

Compatibility Notes

Legacy component behavior will continue to work as before, so your existing integrations won't break. However, when using the Components V2 flag, you'll need to adapt to a few changes:

  • The content and embeds fields will no longer work but you'll be able to use Text Display and Container as replacements
  • Attachments need to be exposed through components to be visible. You can use a Media Gallery, Thumbnail, or File component to display them
  • The poll and stickers fields are disabled
  • A max of 10 top-level components and 30 total components in a message

I don't know the logistics behind migrating to their new structure but I was just getting an error in my bot output:

TypeError: Unsupported component type for {'spoiler': False, 'id': 1, 'components': [{'type': 12, 'items': [{'spoiler': False, 'media': {'width': 1598, 'url': 'https://cdn.discordapp.com/attachments/697138785317814292/1364347504702914602/docs-header.png?ex=68095721&is=680805a1&hm=8391bf267b467d7c919640218c7a8472fcb353cb16ed7e16515489f3799926e8&', 'proxy_url': 'https://media.discordapp.net/attachments/697138785317814292/1364347504702914602/docs-header.png?ex=68095721&is=680805a1&hm=8391bf267b467d7c919640218c7a8472fcb353cb16ed7e16515489f3799926e8&', 'placeholder_version': 1, 'placeholder': 'kscFCYKJ9xCYsJYjRKGAUIk=', 'loading_state': 2, 'id': '1364347506938482720', 'height': 258, 'flags': 0,type': 10, 'id': 3, 'content': "## Introducing New Components for Messages!\nWe're bringing new components to messages that you can use in your apps. They allow you to have full control over the layout of your messages.\n\nOur previous components system, while functional, had limitations:\n- Content, attachments, embeds, and components had to follow fixed positioning rules\n- Visual styling options were limited\n\nOur new component system addresses these challenges with fully composable components that can be arranged and laid out in any order, allowing for a more flexible and visually appealing design. Check out the [changelog](https://discord.com/developers/docs/change-log) for more details."}, {'type': 12, 'items': [{'spoiler': False, 'media': {'width': 4863, 'url': 'https://cdn.discordapp.com/attachments/697138785317814292/1364347505642569850/components-hero.png?ex=68095721&is=680805a1&hm=7af63304916b36b68511b5895d94b756c96c17aed783459dd8003f3564f29604&', 'proxy_url': 'https://media.discordapp.net/attachments/697138785317814292/1364347505642569850/components-hero.png?ex=68095721&is=680805a1&hm=7af63304916b36b68511b5895d94b756c96c17aed783459dd8003f3564f29604&', 'placeholder_version': 1, 'placeholder': 'yveFCYIp8DeidtIvpv1y2EWomYqAd1Y=', 'loading_state': 2, 'id': '1364347506938482721', 'height': 1348, 'flags': 0, 'content_type': 'image/png', 'content_scan_metadata': {'version': 1, 'flags': 0}}, 'description': None}], 'id': 4}, {'type': 9, 'id': 5, 'components': [{'type': 10, 'id': 6, 'content': 'A brief overview of components:'}], 'accessory': {'url': 'https://discord.com/developers/docs/components/overview', 'type': 2, 'style': 5, 'label': 'Overview', 'id': 7}}, {'type': 9, 'id': 8, 'components': [{'type': 10, 'id': 9, 'content': 'A list of all the components:'}], 'accessory': {'url': 'https://discord.com/developers/docs/components/reference#what-is-a-component-component-types', 'type': 2, 'style': 5, 'label': 'Reference', 'id': 10}}, {'type': 9, 'id': 11, 'components': [{'type': 10, 'id': 12, 'content': 'Get started with message components:'}], 'accessory': {'url': 'https://discord.com/developers/docs/components/using-message-components', 'type': 2, 'style': 5, 'label': 'Guide', 'id': 13}}, {'type': 14, 'spacing': 1, 'id': 14, 'divider': True}, {'type': 10, 'id': 15, 'content': '-# This message was composed using components, check out the request:'}, {'type': 13, 'spoiler': False, 'size': 2791, 'name': 'message-data.json', 'id': 16, 'file': {'width': 0, 'url': 'https://cdn.discordapp.com/attachments/697138785317814292/1364347504904114186/message-data.json?ex=68095721&is=680805a1&hm=3945d9d3632a50cddc89185c6dbc85c438cf940cc340ea7ded5a3d61666ec533&', 'proxy_url': 'https://media.discordapp.net/attachments/697138785317814292/1364347504904114186/message-data.json?ex=68095721&is=680805a1&hm=3945d9d3632a50cddc89185c6dbc85c438cf940cc340ea7ded5a3d61666ec533&', 'placeholder_version': None, 'placeholder': None, 'loading_state': 2, 'id': '1364347506938482722', 'height': 0, 'flags': 0, 'content_type': 'application/json; charset=utf-8', 'content_scan_metadata': {'version': 1, 'flags': 0}}}], 'accent_color': None} (17), please consult the docs.

Proposed Solution

Someone who understands this more could migrate interactions.py to use the new discord API, and optionally add any new Components V2 features :)

Alternatives Considered

No response

Additional Information

No response

Code of Conduct

  • I agree to follow the contribution requirements.
@AstreaTSS
Copy link
Member

This has been in the works already as #1760.

@feelixs
Copy link
Author

feelixs commented Apr 22, 2025

This has been in the works already as #1760.

My bad, good to hear

@feelixs feelixs closed this as completed Apr 22, 2025
@AstreaTSS
Copy link
Member

No need to close it, that PR is still in the works 😅. I was simply stating that progress is well underway.

@AstreaTSS AstreaTSS reopened this Apr 22, 2025
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

No branches or pull requests

2 participants