Skip to content

Conversation

@larffxx
Copy link

@larffxx larffxx commented Jul 28, 2025

Pull Request Etiquette

  • I have checked the PRs for upcoming features/bug fixes.
  • I have read the [contributing guidelines][contributing].

Changes

  • Internal code
  • Library interface (affecting end-user code)
  • Documentation
  • Other: _____

Closes Issue: NaN

Description

This PR:
-Adds a representation of a Discord Subscription
-Adds a method in EntityBuilder for create a representation

Copy link
Contributor

@freya022 freya022 left a comment

Choose a reason for hiding this comment

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

* Representation of a Discord Subscription
* <br> This class is immutable
*/
public class Subscription
Copy link
Contributor

Choose a reason for hiding this comment

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

Implement ISnowflake

this.status = status;
}

public Long getId()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public Long getId()
public long getId()

return id;
}

public Long getSubscriberId()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public Long getSubscriberId()
public long getSubscriberId()

}


public JDAImpl getApi()
Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed imo, and also don't expose internals in API

Comment on lines 109 to 111
{
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{
return false;
}
return false;

/**
* Representation of a Discord Subscription Status
*/
public enum SubscriptionStatus
Copy link
Contributor

Choose a reason for hiding this comment

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

Run the formatter on this class

return new Subscription(
getJDA(),
object.getUnsignedLong("id"),
object.getUnsignedLong("user_id", 0),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
object.getUnsignedLong("user_id", 0),
object.getUnsignedLong("user_id"),

);
}

public List<Long> mapDataArrayToLongList(DataArray dataArray)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public List<Long> mapDataArrayToLongList(DataArray dataArray)
private List<Long> mapDataArrayToLongList(DataArray dataArray)

Maybe rename to mapToLongList

Add endpoints with subscriptions
*/
@Nonnull
@CheckReturnValue
RestAction<Subscription> retrieveSubscriptionsBySkuId(long skuId);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should accept a SkuSnowflake instead

*/
@Nonnull
@CheckReturnValue
RestAction<Subscription> retrieveSubscriptionBySkuIdAndSubscriptionId(long skuId, long subscriptionId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to retrieveSubscriptionBySkuId, accept a SkuSnowflake, also make an overload where the subscriptionId is a String.

The overload accepting a String should be implemented, while the long one should be default

@Nonnull
default RestAction<Subscription> retrieveSubscriptionBySkuId(@Nonnull SkuSnowflake sku, long subscriptionId)
{
    return retrieveSubscriptionBySkuId(sku, Long.toUnsignedString(subscriptionId));
}

@Override
public RestAction<Subscription> retrieveSubscriptionsBySkuId(long skuId)
{
return new RestActionImpl<>(this, Route.Sku.GET_SUBSCRIPTIONS.compile(Long.toUnsignedString(skuId)));
Copy link
Contributor

Choose a reason for hiding this comment

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

You have to handle the deserialization

@Override
public RestAction<Subscription> retrieveSubscriptionBySkuIdAndSubscriptionId(long skuId, long subscriptionId)
{
return new RestActionImpl<>(this, Route.Sku.GET_SUBSCRIPTION.compile(Long.toUnsignedString(skuId), Long.toUnsignedString(subscriptionId)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, deserialize

Comment on lines 27 to 29
* The subscription {@link Subscription}
*
* @return The subscription {@link Subscription}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* The subscription {@link Subscription}
*
* @return The subscription {@link Subscription}
* The {@link Subscription}
*
* @return The {@link Subscription}

@@ -0,0 +1,114 @@
package net.dv8tion.jda.api.entities.subscription;
Copy link
Contributor

Choose a reason for hiding this comment

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

Move to internal package

}

/**
* The sku id's related to this
Copy link
Contributor

Choose a reason for hiding this comment

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

SKU is an acronym, so use all caps for it

return subscriberId;
}

public @NotNull List<Long> getSkuIdsLong()
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Use @Nonnull instead
  2. Annotations are on the line before the method declaration

Comment on lines 2129 to 2130
* @param skuId
* The sku id of the List
Copy link
Contributor

Choose a reason for hiding this comment

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

Align with @return, check other javadocs with the same issue

*
* @param skuId
* The sku id of the List
* @return {@link RestAction} - Type: {@link Subscription}
Copy link
Contributor

Choose a reason for hiding this comment

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

There is an extra newline between @param and @return

@EL-JAYY
Copy link

EL-JAYY commented Nov 12, 2025

Just as a little User's view from one that works with the App monetizations. This PR would be a blessing to be implemented with a little priority on it, to be able to see what's happening with subscriptions. Without those you only really get to see when subscriptions end.

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.

4 participants