Skip to content

🚧 Initial Discord message components v2 implementation #1294

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

Merged
merged 29 commits into from
Apr 24, 2025

Conversation

Log1x
Copy link
Member

@Log1x Log1x commented Feb 21, 2025

🚧 Work in progress.

Completely blind & untested. Should be able to try it later today.

Edit: everything appears to be functional.

Screenshot

@valzargaming
Copy link
Member

The v2 contract was an excellent idea, and something I'd like to see in other parts of the library. It would certainly cut down on a lost of instances of checking against hardcoded types like this.

Copy link
Member

@SQKo SQKo left a comment

Choose a reason for hiding this comment

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

Please also adjust the class implements Components\xx to have the namespace imported per my previous suggestion

public function setUrl(string $url): self
{
$this->url = $url;

Copy link
Member

Choose a reason for hiding this comment

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

Implement validation of $url like in Embed::ensureValidUrl()

Copy link
Member

Choose a reason for hiding this comment

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

Do we know if it's the same spec? We could just copy-paste the function here and do the same thing.

Copy link
Member

Choose a reason for hiding this comment

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

I've confirmed it's exactly the same except for File, in which case only attachment is allowed.

@SQKo
Copy link
Member

SQKo commented Feb 23, 2025

According to the spec, using the components v2 may disable content and embeds, it would be good to warn the users in the MessageBuilder to avoid confusion

Also seems this PR has not supported webhooks yet

valzargaming and others added 13 commits February 25, 2025 08:16
Co-authored-by: SQKo <87897282+SQKo@users.noreply.github.com>
Co-authored-by: SQKo <87897282+SQKo@users.noreply.github.com>
Co-authored-by: SQKo <87897282+SQKo@users.noreply.github.com>
Co-authored-by: SQKo <87897282+SQKo@users.noreply.github.com>
Co-authored-by: SQKo <87897282+SQKo@users.noreply.github.com>
Co-authored-by: SQKo <87897282+SQKo@users.noreply.github.com>
PHPDoc specifies the current restrictions on Thumbnail and Button, but the datatype should be left open as Component for now as this list of possible returns may be subject to change.
Co-authored-by: SQKo <87897282+SQKo@users.noreply.github.com>
@Log1x Log1x marked this pull request as ready for review March 23, 2025 04:28
valzargaming
valzargaming previously approved these changes Apr 9, 2025
@valzargaming valzargaming merged commit b8d41da into master Apr 24, 2025
2 checks passed
@valzargaming valzargaming deleted the components-v2 branch June 1, 2025 06:32
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.

4 participants