Skip to content

Conversation

@AV3RG
Copy link

@AV3RG AV3RG commented Jan 13, 2022

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

}
return builder.addFormDataPart("payload_json", json).build();
}
System.out.println("json.toString() = " + json.toString());
Copy link
Owner

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;
Copy link
Owner

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) {
Copy link
Owner

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");
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
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)
Copy link
Owner

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) {
Copy link
Owner

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 {
Copy link
Owner

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() {
Copy link
Owner

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;
Copy link
Owner

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() {
Copy link
Owner

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
@AV3RG
Copy link
Author

AV3RG commented Jan 22, 2022

Fixed most if not all of the issues

@jasonlessenich
Copy link

jasonlessenich commented Jul 23, 2022

What happened to this?

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.

Support for component types such as buttons and select menus

3 participants