Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add monetization support #1803

Merged
merged 18 commits into from Apr 15, 2024
Merged

Conversation

hypergonial
Copy link
Contributor

@hypergonial hypergonial commented Jan 4, 2024

Summary

Add monetization support.

  • Add SKU
  • Add Entitlement
  • Add Gateway events
  • Add REST routes
  • Add interaction response type 10
  • Add REST response builder
  • 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

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

Related issues

Closes #1775

@hypergonial
Copy link
Contributor Author

hypergonial commented Jan 4, 2024

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.

@julien777z
Copy link

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

@julien777z
Copy link

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.

@hypergonial
Copy link
Contributor Author

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.

davfsa
davfsa previously requested changes Jan 21, 2024
Copy link
Member

@davfsa davfsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

hikari/impl/event_factory.py Outdated Show resolved Hide resolved
hikari/events/monetization_events.py Outdated Show resolved Hide resolved
hikari/impl/entity_factory.py Outdated Show resolved Hide resolved
hikari/impl/entity_factory.py Outdated Show resolved Hide resolved
hikari/impl/rest.py Outdated Show resolved Hide resolved
hikari/impl/rest.py Outdated Show resolved Hide resolved
hikari/impl/special_endpoints.py Outdated Show resolved Hide resolved
hikari/interactions/base_interactions.py Outdated Show resolved Hide resolved
hypergonial and others added 5 commits January 21, 2024 13:49
Co-authored-by: davfsa <davfsa@gmail.com>
Signed-off-by: Hyper <git@hypergonial.com>
- Add missing import to init
- Fix some deserialization bugs
- Add missing `__all__`
- Cleanup rest methods
Copy link
Member

@davfsa davfsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes on stuff I need to check out/test

hikari/impl/rest.py Show resolved Hide resolved
hikari/impl/entity_factory.py Outdated Show resolved Hide resolved
hikari/impl/entity_factory.py Outdated Show resolved Hide resolved
hikari/impl/entity_factory.py Outdated Show resolved Hide resolved
hikari/impl/rest.py Show resolved Hide resolved
hikari/impl/rest.py Show resolved Hide resolved
hikari/monetization.py Outdated Show resolved Hide resolved
hikari/monetization.py Outdated Show resolved Hide resolved
tests/hikari/impl/test_entity_factory.py Show resolved Hide resolved
hikari/__init__.py Show resolved Hide resolved
@julien777z
Copy link

any progress on this

@beagold
Copy link
Contributor

beagold commented Apr 3, 2024

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

hikari/api/entity_factory.py Outdated Show resolved Hide resolved
hikari/api/entity_factory.py Outdated Show resolved Hide resolved
hikari/api/event_factory.py Outdated Show resolved Hide resolved
hikari/api/event_factory.py Outdated Show resolved Hide resolved
hikari/api/event_factory.py Show resolved Hide resolved
hikari/impl/rest.py Outdated Show resolved Hide resolved
hikari/interactions/component_interactions.py Outdated Show resolved Hide resolved
hikari/interactions/modal_interactions.py Outdated Show resolved Hide resolved
hikari/internal/routes.py Show resolved Hide resolved
hikari/monetization.py Outdated Show resolved Hide resolved
@beagold
Copy link
Contributor

beagold commented Apr 14, 2024

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

@beagold
Copy link
Contributor

beagold commented Apr 15, 2024

Everything sorted and should be good to merge!

@beagold beagold dismissed davfsa’s stale review April 15, 2024 06:59

No longer relevant

@beagold beagold merged commit 318a670 into hikari-py:master Apr 15, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement monetization
4 participants