Recipes

Monetization

With Seyfert you can now control the latest Discord monetization features.

This section will show the basic creation of premium buttons, events and commands.

Activate Monetization

First you need to activate the monetization in your bot for all this to work, learn how to do it here

Entitlements

Entitlements in Discord represent that a user or guild has access to a premium offering in your application, with this you can know if a user is subscribed to your application and give him the benefits you want.

Receiving Events

Currently there are 3 events for entitlements:

entitlementCreate(entitlement: Entitlement)

Emitted whenever an entitlement is created.

entitlementDelete(entitlement: Entitlement)

Emitted whenever an entitlement is deleted. Entitlements are not deleted when they expire. This is only triggered when Discord issues a refund or deletes the entitlement manually.

entitlementUpdate(entitlement: Entitlement)

Emitted whenever an entitlement is updated - i.e. when a user's subscription renews.

export default ({
    : { : 'entitlementCreate' },
    async (, ) {
        if (!.) return;
        const  = await ..(.);
        ..('LOG_CHANNEL_ID', {
            : `${.} (${.}) has been subscribed to ${.}`,
        });
    },
});

Premium Button

Now you can create a Button that redirects to any item in your store, such as a subscription, consumable, etc.

This type of button does not need a CustomID or Label, but it does need a SkuID, which you can get from your store menu at https://discord.com/developers/applications/{APP_ID}/skus

import {  } from 'seyfert';
import {  } from 'seyfert/lib/types';
 
new ()
.('STORE_ITEM_SKU_ID')
.(.)

Learn more

For more information about the premium buttons visit the discord documentation here

Commands / Interactions

In each Interaction you can also get all the active entitlements, with them you can detect if the user has any subscriptions, consumables, etc.

Example:

import { , , type , ,  } from 'seyfert';
import {  } from 'seyfert/lib/types';
 
@({
  : 'premium',
  : 'Premium command',
})
export class  extends   {
  (: ) {
    const  = ...;
 
    const  = new ()
    .([
        new ()
        .('STORE_ITEM_SKU_ID')
        .(.)
    ]);
 
    if (!) return .({ 
        : 'Click to subscribe and get access to the command!',
        : [] 
    });
 
    // Premium code
  }
}

On this page