hikari
hikari copied to clipboard
Add monetization support
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 theEntitlementOwnerType
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
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.
This needs to be added to hikari.__init__.py
:
from hikari.events.monetization_events import *
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.
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.
any progress on this
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
Added some comments in addition to what @davfsa already pointed out
Everything sorted and should be good to merge!