#How to get started with Monetization in Discord.NET?
1 messages · Page 1 of 1 (latest)
you will have to connect to a database.
i have a database in place thats no issue
Or, you can give a role to a user
but i need a way to know what user has it and who doesnt
if the paiement is valid
its not my server its the default discord monetization i want to use
bot can be on any server
what do you mean by default discord monetization ?
where do you find it ?
in the developer panel of my bot
cant see more info abt it rn cause thats stuff i wanna do after i got a stable version of it
I'm not sure Discord.NET has wrapped this monetization part of the api
And i think this is not the behaviour you want
wym
It's to make server owner paid to integrate your bot in their server
You can't make each user of the server pay to use the bot
You'll have to integrate a payment gateway within your bot
like paypal or stripe
Premium App Subscriptions are a monthly subscription to premium features of an app that any individual member or server admin in a server can purchase to get enhanced functionality and more commands for the app.
Ok nevermind then
if an admin buys it the whole server gets it apparently
nvm thats a guild subscription thats another thing
yes
i can find the state
but nothing more
@earnest brook
np
Yeah so we definitely need to write guides on monetization (I was going to do this , oops) BUT the library support is definitely here.
you will have to do a few things to handle "entitlements"
Client.EntitlementCreated += EntitlementCreated;
Client.EntitlementDeleted += EntitlementDeleted;
Client.EntitlementUpdated += EntitlementUpdated;
the EntitlementCreated and EntitlementUpdated are the most important
this is where you would handle giving a user premium.
aside from those events, is there a REST call for any current running or previously bought SKUs in case of a bot downtime
gimme a sec
a feature where you could restrict certain interactions to an SKU would be cool for Discord.NET
tbh idk
BUT
you can check it in an interaction
Context.Interaction.Entitlements in a command for exmaple
perfect
tysm!
public static bool IsPremium(IReadOnlyCollection<RestEntitlement> entitlements)
{
return entitlements.Count > 0 && entitlements.FirstOrDefault(x => x.SkuId == 1169107771673812992) is not null;
}
something like this
yas
except obviously ur skuid
You figure this out?
ill implement it in a few days or hours depending on when i next want to work on the bot, i dont want to release it and instantly add a feature for monetization when there are some bugs to fix
ill respond to you when i start implementing this and or have my first results tho
also for testing, will discord allow me to purchase my own SKU for free sort of like a debug or do i actually have to buy it
Yes you can do it for free
Something i did was start a second instant of the bot and not accept commands on it just premium stuff for testing
How would guild entitlements be handled?
I saw that all sorts of Interactions had an Entitlement parameter but the Guild did not
Is that included in the interactions entitlement?
Also is it even important to store entitlements since discord seems to send them on every interaction anyways?
so you need to handle the entitlement events but not interaction received or created or stuff like thatr
Ah
now this, is a fun question which I am unsure of how to answer
I mean I should save them if I'm adding stuff like a dashboard for them or a special role or something since that's data I don't change or check on every interaction like I can't set that role only for then etc
But I think I'd be fine currently with just checking each interaction since I don't give the users any special role atm cause of how the bot is built
I mean whatever works for you

Even if shit hits the fan I'll make sure to always have an easy way for users to submit a feedback form
so im now working with Entitlements and i have a few questions
- how can i test this
- how can i properly write a handler for consumable entitlements and subscriptions, since i saw that the SocketClient has a function called ConsumeEntitlement but i dont understand it
So depends on what you wanna test but you can go about it a few ways.
i figured it out
had to enable app test mode
writing my handler atm
for one time purchases i just need to handle it and consume it for subs discord will send me the entitlement
essentially
personally I have never used the app test mode I just made a seconds instance of my bot and then only had the premium commands being tested deployed from that instance
I thought you could always buy stuff from your app and not be charged
i wrote an extension method for my User object called IsPremium now i can check the object directly