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 v2 #1190

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

feat!: components v2 #1190

wants to merge 7 commits into from

Conversation

advaith1
Copy link
Contributor

@advaith1 advaith1 commented Jan 8, 2025

Please describe the changes this PR makes and why it should be merged:

uikit/components v2 :)

If applicable, please reference Discord API Docs PRs or commits that influenced this PR:

soon tm

Copy link

vercel bot commented Jan 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
discord-api-types ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 20, 2025 1:02am

@github-actions github-actions bot added the chore label Feb 7, 2025
@vladfrangu vladfrangu changed the title feat(Components): wip uikit feat!: components v2 Feb 16, 2025
@vladfrangu
Copy link
Member

vladfrangu commented Feb 16, 2025

I've published discord-api-types@pr-1190. Install using npm i discord-api-types@pr-1190 or your preferred package manager.

Publish command for future use

npm publish --tag pr-1190 --provenance=false

export type APIMessageComponent =
| APIMessageActionRowComponent
| APIMessageTopLevelComponent
| APISectionAccessoryComponent;
Copy link
Member

Choose a reason for hiding this comment

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

Really? Buttons work too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well buttons are already in APIMessageActionRowComponent - I think this type is just any component that can be anywhere inside a message

@@ -914,6 +914,10 @@ export enum MessageFlags {
* This message has a snapshot (via Message Forwarding)
*/
HasSnapshot = 1 << 14,
/**
* This flag is required to use new components

Choose a reason for hiding this comment

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

You may want to consider adding documentation around what this flag actually does (additional components, restrictions on other fields, etc). Additionally, these components wont be "new" forever, so improved documentation may be in order

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently descriptions are temporarily copied from the alpha readme - once the docs pr is out with proper descriptions we'll use those

/**
* int32, auto generated via increment if not provided
*/
id?: number;

Choose a reason for hiding this comment

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

Not sure how discord-api-types would want to model it, but id is optional on request, but will always be provided as part of the response.

Copy link
Member

Choose a reason for hiding this comment

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

We have other places where that's an issue, usually we either create rest-specific types from the api ones or document it as always present when received

Comment on lines +1940 to +1947
proxy_url?: string;
width?: number | null;
height?: number | null;
placeholder?: string | null;
placeholder_version?: number | null;
content_type?: string | null;
loading_state?: UnfurledMediaItemLoadingState;
flags?: number;

Choose a reason for hiding this comment

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

Unclear if discord-api-types has a separation between request and response models, but url is the only dev-settable field. All others are provided by discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants