Skip to main content

Supporter

The supporter module decides who may use which part of your bot. It knows your subscriptions, the features they unlock and the commands that need them, and it checks every interaction before jda-commands runs it.

implementation("dev.chojo.aether:supporter:2.0.0")

The pieces​

TermMeaning
SubscriptionSomething a user or guild can buy, for example "Supporter". It has a numeric id and the ids it has on each platform.
PlatformWhere it was bought: Platform.DISCORD, Platform.KOFI or Platform.PATREON.
Purchase typePurchaseType.SUBSCRIPTION (recurring) or PurchaseType.LIFETIME (bought once).
FeatureSomething your bot offers that needs a subscription, for example a custom profile.
Interaction ruleA command that needs a subscription, by its full command name.
Subscription contextThe set of ids a user or guild has right now. Access checks compare it with the ids a feature or command needs.

A feature or command is open to everyone when its list of ids is empty. Otherwise the subscription context must contain one of the listed ids.

What you provide​

Aether stores nothing itself. You implement:

TypePurpose
SubscriptionContextProviderReturns the subscription context of a user and of a guild, usually from your database.
ISupporterErrorSupplierThe message a user sees when a command is locked.
ISubscriptionsThe subscriptions of one guild, with add, delete and clear. Used by the entitlement and Ko-fi services.
ADiscordPurchase and AEntitlementServiceOnly for Discord purchases. See Discord entitlements.

The services call ISubscriptions.deleteSubscription with a new Subscription object. It equals the stored one when subscription id, target id, target type and platform match, so List.remove finds it.

Where to go next​

  1. Configuration: describe your subscriptions, features and locked commands.
  2. Access checks: plug the middleware into jda-commands and check features in your commands.
  3. Discord entitlements: turn Discord purchases into subscriptions.
  4. Ko-fi: turn Ko-fi purchases into subscriptions.