Skip to content

feat: components v2 #2707

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
wants to merge 162 commits into
base: master
Choose a base branch
from

Conversation

NeloBlivion
Copy link
Member

@NeloBlivion NeloBlivion commented Feb 6, 2025

Summary

Soon




Information

  • 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, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

Reference:

message-components-v2-text-display
message-components-v2-container
message-components-v2-file
message-components-v2-media-gallery
message-components-v2-section
message-components-v2-separator

@Lulalaby Lulalaby added discord limitation Limitation imposed by discord priority: medium Medium Priority status: in progress Work in Progess feature Implements a feature upcoming discord feature Involves a feature not yet fully released by Discord labels Feb 6, 2025
@Lulalaby Lulalaby added this to the v2.7 milestone Feb 6, 2025
NeloBlivion and others added 7 commits April 23, 2025 14:31
thank u for proofreading

Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>
Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com>
Signed-off-by: plun1331 <plun1331@gmail.com>
@NeloBlivion
Copy link
Member Author

When using a decorator in a container, should the items appear above or below items set in __init__

@Icebluewolf
Copy link
Contributor

Can row not be used? But I would say below when not specified.

Copy link
Member

@plun1331 plun1331 left a comment

Choose a reason for hiding this comment

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

disable_all_items and enable_all_items need to be updated

@@ -1605,6 +1605,8 @@ async def send(
)

components = view.to_components()
if view.is_components_v2():
flags.is_components_v2 = True
Copy link
Member

Choose a reason for hiding this comment

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

We should add an error here if content or embeds are provided, because some of the discord errors aren't very clear


class File(Item[V]):
"""Represents a UI File.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.. note::
This component does not show media previews. Use :class:`MediaGallery` for previews instead.

.. versionadded:: 2.7

Parameters
----------
Copy link
Member

Choose a reason for hiding this comment

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

Parameters

Parameters
----------
*items: :class:`MediaGalleryItem`
The initial items contained in this gallery, up to 10.
Copy link
Member

Choose a reason for hiding this comment

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

Document id

----------
content: :class:`str`
The text display's content.
"""
Copy link
Member

Choose a reason for hiding this comment

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

document id

.. versionadded:: 2.7

Parameters
----------
Copy link
Member

Choose a reason for hiding this comment

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

parameters

if view is not MISSING:
payload["components"] = view.to_components() if view is not None else []
if view and view.is_components_v2():
flags.is_components_v2 = True
Copy link
Member

Choose a reason for hiding this comment

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

Error if content or embeds are sent with this flag enabled

@button(label="Delete Message", style=ButtonStyle.red, id=200)
async def delete_button(self, button: Button, interaction: Interaction):
await interaction.response.defer(invisible=True)
await interaction.delete_original_response()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
await interaction.delete_original_response()
await interaction.message.delete()

Copy link
Member Author

Choose a reason for hiding this comment

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

I think officially delete_original_response is recommended because defer is a response?

Copy link
Member

Choose a reason for hiding this comment

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

delete_original_response deletes whatever response you sent, it looks like what you want is to delete the message the button is on

Copy link
Contributor

Choose a reason for hiding this comment

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

I think having an edit button would be more useful in this scenario anyways, then the id functionality can be shown. That change can be made in a future PR though.

NeloBlivion and others added 8 commits April 24, 2025 18:40
Co-authored-by: plun1331 <plun1331@gmail.com>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>
Co-authored-by: plun1331 <plun1331@gmail.com>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>
Co-authored-by: Paillat <jeremiecotti@ik.me>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>
Co-authored-by: Paillat <jeremiecotti@ik.me>
Signed-off-by: UK <41271523+NeloBlivion@users.noreply.github.com>
@@ -137,6 +137,7 @@ def add_item(self, item: Item) -> None:

self.items.append(item)
self._add_component_from_item(item)
return self
Copy link
Contributor

Choose a reason for hiding this comment

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

The return types need to be changed to typing.Self

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discord limitation Limitation imposed by discord feature Implements a feature hold: changelog This pull request is missing a changelog entry priority: medium Medium Priority status: in progress Work in Progess upcoming discord feature Involves a feature not yet fully released by Discord
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

7 participants