-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
Components V2! #2196
base: master
Are you sure you want to change the base?
Components V2! #2196
Conversation
This reverts commit c55c00b.
… collected before it can be fully implemented.
Signed-off-by: Platy <contact@mplaty.com>
…t builder api classes)
…ents now contain the id object, along with the builders supporting the ID object.
…ata, and be more easily built, along with fixing an error with the MessageFileBuilder.
@@ -172,6 +172,9 @@ class MessageFlag(enums.Flag): | |||
IS_VOICE_MESSAGE = 1 << 13 | |||
"""This message is a voice message.""" | |||
|
|||
IS_COMPONENTS_V2 = 1 << 15 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we automatically detect and set it when making the request instead of having users set it?
This flag is an unfortunate implementation decision that cannot be removed (as stated by devs), so we could at least remove it for the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can, but there is a few components that are both v1 and v2 supportive, like the action row, and I believe they act different if you use the flag vs not use it. We could make it so any components that require the V2 flag, automatically adds it, but I would still leave the option for the end user to add it as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was my idea, force it when a components v2 is used
proxy_resource: typing.Optional[files.Resource[files.AsyncReader]] = attrs.field(default=None, repr=False) | ||
"""The proxied version of the resource, or [`None`][] if not present. | ||
|
||
!!! note | ||
This field cannot be set by bots or webhooks while sending an embed | ||
and will be ignored during serialization. Expect this to be | ||
populated on any received embed attached to a message event. | ||
""" | ||
|
||
width: undefined.UndefinedNoneOr[int] = attrs.field(repr=True) | ||
"""The width of media item.""" | ||
|
||
height: undefined.UndefinedNoneOr[int] = attrs.field(repr=True) | ||
"""The height of the media item.""" | ||
|
||
content_type: undefined.UndefinedNoneOr[str] = attrs.field(repr=True) | ||
"""The content type of the media item.""" | ||
|
||
loading_state: undefined.UndefinedNoneOr[MediaLoadingType] = attrs.field(repr=True) | ||
"""The loading state of the media item.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should never be allowed to be undefined, and in some cases, None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proxy_resource
seems fine imo, unless it should be undefined.UndefinedOr[...]
otherwise, should the rest just be typing.Optional[...]
?
description: typing.Optional[str] = attrs.field() | ||
"""The description of the thumbnail.""" | ||
|
||
spoiler: typing.Optional[bool] = attrs.field() | ||
"""If the thumbnail has a spoiler.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never None
"""The description of the thumbnail.""" | ||
|
||
spoiler: typing.Optional[bool] = attrs.field() | ||
"""If the thumbnail has a spoiler.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""If the thumbnail has a spoiler.""" | |
"""Whether the thumbnail is marked as a spoiler.""" |
components: typing.Sequence[TextDisplayComponent] = attrs.field() | ||
"""The sections components.""" | ||
|
||
accessory: typing.Union[ButtonComponent, ThumbnailComponent] = attrs.field() | ||
"""The sections accessory.""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update to use the new typehints
"""The description of the gallery item.""" | ||
|
||
spoiler: bool = attrs.field() | ||
"""If the gallery item has a spoiler.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""If the gallery item has a spoiler.""" | |
"""Whether the gallery item is marked as a spoiler.""" |
accent_color: undefined.UndefinedNoneOr[colors.Color] = attrs.field() | ||
"""The accent colour for the container. | ||
|
||
If undefined, no accent color is set. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accent_color: undefined.UndefinedNoneOr[colors.Color] = attrs.field() | |
"""The accent colour for the container. | |
If undefined, no accent color is set. | |
""" | |
accent_color: typing.Optional[colors.Color] = attrs.field() | |
"""The accent colour for the container.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The accent colour has three states, hidden = omitted (makes the message look like its got a box around it and thats it), default = None (the default colour value and then a colour) so wouldn't the original make more sense?
|
Co-authored-by: davfsa <davfsa@gmail.com> Signed-off-by: Platy <mplatypus54@gmail.com>
Summary
Adds support for components V2!
Checklist
nox
and all the pipelines have passed.Related issues