hikari icon indicating copy to clipboard operation
hikari copied to clipboard

Add monetization support

Open hypergonial opened this issue 1 year ago • 4 comments

Summary

Add monetization support.

  • [x] Add SKU
  • [x] Add Entitlement
  • [x] Add Gateway events
  • [x] Add REST routes
  • [x] Add interaction response type 10
  • [x] Add REST response builder
  • [x] Add interaction.entitlements property

Notes/Questions

  • Should create_test_entitlement take in a user/guild object instead of the EntitlementOwnerType being the toggle?
  • SKU object is missing several fields that are simply not or partially documented, to my knowledge these are unused by apps
  • Entitlement object includes a subscription_id which is only partially documented but seems to be referenced so may be important? Unclear.

Checklist

  • [x] I have run nox and all the pipelines have passed.
  • [x] I have made unittests according to the code I have added/modified/deleted.

Related issues

Closes #1775

hypergonial avatar Jan 04 '24 20:01 hypergonial

I added tests for all the things implemented in this PR afaict, not sure why codeclimate is still failing.

Edit: Looks like the commit below completely broke CI, lol.

hypergonial avatar Jan 04 '24 21:01 hypergonial

This needs to be added to hikari.__init__.py: from hikari.events.monetization_events import *

julien777z avatar Jan 10 '24 00:01 julien777z

For create_test_entitlement I would prefer a guild and user kwarg, so something like this:

await bot.rest.create_test_entitlement(
    event.interaction.application_id,
    sku="1",
    guild="1",
)
await bot.rest.create_test_entitlement(
    event.interaction.application_id,
    sku="1",
    user="1",
)

Then raise an exception if they specify both.

Or, "owner" kwarg that can be a user or guild, but if they specify just the snowflake ID, make it required to specify owner_type. In other words:

await bot.rest.create_test_entitlement(
    event.interaction.application_id,
    sku="1",
    owner="1",
    owner_type=hikari.monetization.EntitlementOwnerType.GUILD
)
await bot.rest.create_test_entitlement(
    event.interaction.application_id,
    sku="1",
    owner=await bot.rest.fetch_guild("1"),
)

would be equivalent.

Personally, I like the first one with separate user and guild args.

julien777z avatar Jan 10 '24 00:01 julien777z

For create_test_entitlement I would prefer a guild and user kwarg, so something like this:

await bot.rest.create_test_entitlement(
    event.interaction.application_id,
    sku="1",
    guild="1",
)
await bot.rest.create_test_entitlement(
    event.interaction.application_id,
    sku="1",
    user="1",
)

Then raise an exception if they specify both.

Or, "owner" kwarg that can be a user or guild, but if they specify just the snowflake ID, make it required to specify owner_type. In other words:

await bot.rest.create_test_entitlement(
    event.interaction.application_id,
    sku="1",
    owner="1",
    owner_type=hikari.monetization.EntitlementOwnerType.GUILD
)
await bot.rest.create_test_entitlement(
    event.interaction.application_id,
    sku="1",
    owner=await bot.rest.fetch_guild("1"),
)

would be equivalent.

Personally, I like the first one with separate user and guild args.

I personally feel like that hikari should try to closely mirror the Discord API, wherever possible, so I'm against this idea, but if the maintainers feel otherwise, I'll adjust it.

hypergonial avatar Jan 10 '24 23:01 hypergonial

any progress on this

julien777z avatar Apr 02 '24 22:04 julien777z

any progress on this

As far as I am aware, it should just be the comments above. I'll ask around and check this out later today

beagold avatar Apr 03 '24 10:04 beagold

Added some comments in addition to what @davfsa already pointed out

beagold avatar Apr 14 '24 12:04 beagold

Everything sorted and should be good to merge!

beagold avatar Apr 15 '24 06:04 beagold