Skip to content

Instantly share code, notes, and snippets.

@msciotti
Created May 13, 2019 21:51
Show Gist options
  • Save msciotti/9b4bc22a0955f00ab4988aca2d97b1e6 to your computer and use it in GitHub Desktop.
Save msciotti/9b4bc22a0955f00ab4988aca2d97b1e6 to your computer and use it in GitHub Desktop.
int main(int, char**)
{
discord::Core* core{};
auto result = discord::Core::Create(MY_APPLICATION_ID, DiscordCreateFlags_Default, &core);
core->StoreManager().FetchSkus();
core->StoreManager().OnEntitlementCreate.Connect(
[&](discord::Entitlement const& entitlement) -> {
discord::Sku* sku{};
core->StoreManager().GetSku(entitlement.SkuId, &sku);
if (sku.Type == discord::SkuType::Consumable) {
// "Consume" the entitlement
// https://discordapp.com/developers/docs/game-sdk/store#consume-sku
}
// Give the user what they bought
});
// Call StartPurchase on the SKU you want the user to buy
// The SKU ID will be dependent on what the user selects in-game to buy
core->StoreManager().StartPurchase(CHOSEN_SKU_ID,
[&](discord::Result result) {
if (result == discord::Result::Ok) {
std::cout << "User is in purchase dialogue";
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment