Skip to content

Commit

Permalink
Added missing properties to ApplicationInfo (discord-jda#2605)
Browse files Browse the repository at this point in the history
  • Loading branch information
freya022 authored Jan 21, 2024
1 parent 8d3480a commit 4854d5c
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
33 changes: 33 additions & 0 deletions src/main/java/net/dv8tion/jda/api/entities/ApplicationInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,39 @@ default String getInviteUrl(long guildId, @Nullable Permission... permissions)
@Nonnull
List<String> getTags();

/**
* A {@link java.util.List} containing the OAuth2 redirect URIs of this bot's application.
*
* <p>This List is empty if no redirect URIs are set in the <a href="https://discord.com/developers/applications" target="_blank">Developer Portal</a>.
*
* @return Immutable list containing the OAuth2 redirect URIs of this bot's application
*/
@Nonnull
List<String> getRedirectUris();

/**
* The interaction endpoint URL of this bot's application.
*
* <p>This returns {@code null} if no interaction endpoint URL is set in the <a href="https://discord.com/developers/applications" target="_blank">Developer Portal</a>.
*
* <p>A non-null value means your bot will no longer receive {@link net.dv8tion.jda.api.interactions.Interaction interactions}
* through JDA, such as slash commands, components and modals.
*
* @return Interaction endpoint URL of this bot's application, or {@code null} if it has not been set
*/
@Nullable
String getInteractionsEndpointUrl();

/**
* The role connections (linked roles) verification URL of this bot's application.
*
* <p>This returns {@code null} if no role connection verification URL is set in the <a href="https://discord.com/developers/applications" target="_blank">Developer Portal</a>.
*
* @return Role connections verification URL of this bot's application, or {@code null} if it has not been set
*/
@Nullable
String getRoleConnectionsVerificationUrl();

/**
* The custom Authorization URL of this bot's application.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@ public class ApplicationInfoImpl implements ApplicationInfo
private final User owner;
private final ApplicationTeam team;
private final List<String> tags;
private final List<String> redirectUris;
private final String interactionsEndpointUrl;
private final String roleConnectionsVerificationUrl;
private final String customAuthUrl;
private final long defaultAuthUrlPerms;
private final List<String> defaultAuthUrlScopes;
private String scopes = "bot";

public ApplicationInfoImpl(JDA api, String description, boolean doesBotRequireCodeGrant, String iconId, long id, long flags,
boolean isBotPublic, String name, String termsOfServiceUrl, String privacyPolicyUrl, User owner, ApplicationTeam team,
List<String> tags, String customAuthUrl, long defaultAuthUrlPerms, List<String> defaultAuthUrlScopes)
List<String> tags, List<String> redirectUris, String interactionsEndpointUrl, String roleConnectionsVerificationUrl,
String customAuthUrl, long defaultAuthUrlPerms, List<String> defaultAuthUrlScopes)
{
this.api = api;
this.description = description;
Expand All @@ -69,6 +73,9 @@ public ApplicationInfoImpl(JDA api, String description, boolean doesBotRequireCo
this.owner = owner;
this.team = team;
this.tags = Collections.unmodifiableList(tags);
this.redirectUris = Collections.unmodifiableList(redirectUris);
this.interactionsEndpointUrl = interactionsEndpointUrl;
this.roleConnectionsVerificationUrl = roleConnectionsVerificationUrl;
this.customAuthUrl = customAuthUrl;
this.defaultAuthUrlPerms = defaultAuthUrlPerms;
this.defaultAuthUrlScopes = Collections.unmodifiableList(defaultAuthUrlScopes);
Expand Down Expand Up @@ -207,6 +214,27 @@ public List<String> getTags()
return tags;
}

@Nonnull
@Override
public List<String> getRedirectUris()
{
return redirectUris;
}

@Nullable
@Override
public String getInteractionsEndpointUrl()
{
return interactionsEndpointUrl;
}

@Nullable
@Override
public String getRoleConnectionsVerificationUrl()
{
return roleConnectionsVerificationUrl;
}

@Nullable
@Override
public String getCustomAuthorizationUrl()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2476,6 +2476,11 @@ public ApplicationInfo createApplicationInfo(DataObject object)
final List<String> tags = object.optArray("tags").orElseGet(DataArray::empty)
.stream(DataArray::getString)
.collect(Collectors.toList());
final List<String> redirectUris = object.optArray("redirect_uris").orElseGet(DataArray::empty)
.stream(DataArray::getString)
.collect(Collectors.toList());
final String interactionsEndpointUrl = object.getString("interactions_endpoint_url", null);
final String roleConnectionsVerificationUrl = object.getString("role_connections_verification_url", null);

final Optional<DataObject> installParams = object.optObject("install_params");

Expand All @@ -2488,7 +2493,8 @@ public ApplicationInfo createApplicationInfo(DataObject object)
.orElse(Collections.emptyList());

return new ApplicationInfoImpl(getJDA(), description, doesBotRequireCodeGrant, iconId, id, flags, isBotPublic, name,
termsOfServiceUrl, privacyPolicyUrl, owner, team, tags, customAuthUrl, defaultAuthUrlPerms, defaultAuthUrlScopes);
termsOfServiceUrl, privacyPolicyUrl, owner, team, tags, redirectUris, interactionsEndpointUrl,
roleConnectionsVerificationUrl, customAuthUrl, defaultAuthUrlPerms, defaultAuthUrlScopes);
}

public ApplicationTeam createApplicationTeam(DataObject object)
Expand Down

0 comments on commit 4854d5c

Please sign in to comment.