-
Notifications
You must be signed in to change notification settings - Fork 35
Added support for components for webhooks #56
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
Conversation
| } | ||
| return builder.addFormDataPart("payload_json", json).build(); | ||
| } | ||
| System.out.println("json.toString() = " + json.toString()); |
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.
Remove this
| */ | ||
| public boolean isEmpty() { | ||
| return content.length() == 0 && embeds.isEmpty() && getFileAmount() == 0; | ||
| return content.length() == 0 && embeds.isEmpty() && components.isEmpty() && getFileAmount() == 0; |
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.
Components are not a full message, this check is wrong.
| * If more than {@value LayoutComponent#MAX_COMPONENTS} are added | ||
| */ | ||
| @NotNull | ||
| public WebhookMessageBuilder addComponents(LayoutComponent... components) { |
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.
This is missing annotations for parameters
| public WebhookMessageBuilder addComponents(LayoutComponent... components) { | ||
| Objects.requireNonNull(components, "Components"); | ||
| if (this.components.size() + components.length > 5) | ||
| throw new IllegalStateException("Cannot have more than 5 action rows in a message"); |
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.
| throw new IllegalStateException("Cannot have more than 5 action rows in a message"); | |
| throw new IllegalStateException("Cannot have more than 5 component layouts in a message"); |
| @NotNull | ||
| public WebhookMessageBuilder addComponents(LayoutComponent... components) { | ||
| Objects.requireNonNull(components, "Components"); | ||
| if (this.components.size() + components.length > 5) |
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.
This should be a constant
| * @param value The dev-defined value for the option | ||
| * @return A SelectOption with the provided label and value | ||
| */ | ||
| public static SelectOption of(@NotNull String label, @NotNull String value) { |
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.
Annotations missing
| /** | ||
| * Components that can be inserted inside layout components (buttons & select menus) | ||
| */ | ||
| public interface ActionComponent extends Component { |
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.
Add withDisabled and isDisabled to this, with overrides on button and select menu to return their respective types.
| } | ||
|
|
||
| @JSONPropertyIgnore | ||
| public boolean isDef() { |
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.
This is undescriptive, I have no idea what this getter is.
| private final String value; | ||
| private final String description; | ||
| private PartialEmoji emoji; | ||
| private final boolean def; |
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.
Call this isDefault to avoid the keyword error
|
|
||
| @NotNull | ||
| @JSONPropertyIgnore | ||
| public String getLabel() { |
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.
All these getters need docs
Added missing annotations Added SingleEmojiContainer
|
Fixed most if not all of the issues |
|
What happened to this? |
Fixes #46
Components are only supported for application owned webhooks.
Other webhooks wont work with components due to discord limitations.
Please review the java docs once, I am bad at documenting