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
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/1803.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add monetization support.
2 changes: 2 additions & 0 deletions hikari/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
from hikari.events.lifetime_events import *
from hikari.events.member_events import *
from hikari.events.message_events import *
from hikari.events.monetization_events import *
beagold marked this conversation as resolved.
Show resolved Hide resolved
from hikari.events.reaction_events import *
from hikari.events.role_events import *
from hikari.events.scheduled_events import *
Expand Down Expand Up @@ -113,6 +114,7 @@
from hikari.iterators import *
from hikari.locales import *
from hikari.messages import *
from hikari.monetization import *
from hikari.permissions import *
from hikari.presences import *
from hikari.scheduled_events import *
Expand Down
2 changes: 2 additions & 0 deletions hikari/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ from hikari.events.interaction_events import *
from hikari.events.lifetime_events import *
from hikari.events.member_events import *
from hikari.events.message_events import *
from hikari.events.monetization_events import *
from hikari.events.reaction_events import *
from hikari.events.role_events import *
from hikari.events.scheduled_events import *
Expand Down Expand Up @@ -87,6 +88,7 @@ from hikari.invites import *
from hikari.iterators import *
from hikari.locales import *
from hikari.messages import *
from hikari.monetization import *
from hikari.permissions import *
from hikari.presences import *
from hikari.scheduled_events import *
Expand Down
35 changes: 35 additions & 0 deletions hikari/api/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from hikari import guilds as guild_models
from hikari import invites as invite_models
from hikari import messages as message_models
from hikari import monetization as entitlement_models
from hikari import presences as presence_models
from hikari import scheduled_events as scheduled_events_models
from hikari import sessions as gateway_models
Expand Down Expand Up @@ -1994,3 +1995,37 @@ def deserialize_webhook(self, payload: data_binding.JSONObject) -> webhook_model
hikari.errors.UnrecognisedEntityError
If the channel type is unknown.
"""

##################
# MONETIZATION #
##################

@abc.abstractmethod
def deserialize_entitlement(self, payload: data_binding.JSONObject) -> entitlement_models.Entitlement:
"""Parse a raw payload from Discord into an entitlement object.

Parameters
----------
payload : hikari.internal.data_binding.JSONObject
The JSON payload to deserialize.

Returns
-------
monetization_models.Entitlement
beagold marked this conversation as resolved.
Show resolved Hide resolved
The deserialized entitlement object.
"""

@abc.abstractmethod
def deserialize_sku(self, payload: data_binding.JSONObject) -> entitlement_models.SKU:
"""Parse a raw payload from Discord into an SKU object.

Parameters
----------
payload : hikari.internal.data_binding.JSONObject
The JSON payload to deserialize.

Returns
-------
monetization_models.SKU
beagold marked this conversation as resolved.
Show resolved Hide resolved
The deserialized SKU object.
"""
59 changes: 59 additions & 0 deletions hikari/api/event_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from hikari.events import lifetime_events
from hikari.events import member_events
from hikari.events import message_events
from hikari.events import monetization_events
from hikari.events import reaction_events
from hikari.events import role_events
from hikari.events import scheduled_events
Expand Down Expand Up @@ -1394,3 +1395,61 @@ def deserialize_voice_server_update_event(
hikari.events.voice_events.VoiceServerUpdateEvent
The parsed voice server update event object.
"""

##################
# MONETIZATION #
##################

@abc.abstractmethod
def deserialize_entitlement_create_event(
self, shard: gateway_shard.GatewayShard, payload: data_binding.JSONObject
) -> monetization_events.EntitlementCreateEvent:
"""Parse a raw payload from Discord into a entitlement create event object.

Parameters
----------
shard : hikari.api.shard.GatewayShard
The shard that emitted this event.
payload : hikari.internal.data_binding.JSONObject
beagold marked this conversation as resolved.
Show resolved Hide resolved

Returns
-------
hikari.events.entitlement_events.EntitlementCreateEvent
The parsed entitlement create event object.
"""

@abc.abstractmethod
def deserialize_entitlement_delete_event(
self, shard: gateway_shard.GatewayShard, payload: data_binding.JSONObject
) -> monetization_events.EntitlementDeleteEvent:
"""Parse a raw payload from Discord into a entitlement delete event object.

Parameters
----------
shard : hikari.api.shard.GatewayShard
The shard that emitted this event.
payload: hikari.internal.data_binding.JSONObject
beagold marked this conversation as resolved.
Show resolved Hide resolved

Returns
-------
hikari.events.entitlement_events.EntitlementDeleteEvent
The parsed entitlement delete event object.
"""

@abc.abstractmethod
def deserialize_entitlement_update_event(
self, shard: gateway_shard.GatewayShard, payload: data_binding.JSONObject
) -> monetization_events.EntitlementUpdateEvent:
"""Parse a raw payload from Discord into a entitlement update event object.

Parameters
----------
shard : hikari.api.shard.GatewayShard
The shard that emitted this event.
payload: hikari.internal.data_binding.JSONObject
beagold marked this conversation as resolved.
Show resolved Hide resolved

Returns
-------
hikari.events.entitlement_events.EntitlementUpdateEvent
The parsed entitlement update event object.
"""
4 changes: 3 additions & 1 deletion hikari/api/interaction_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
_InteractionT_co = typing.TypeVar("_InteractionT_co", bound=base_interactions.PartialInteraction, covariant=True)
_ResponseT_co = typing.TypeVar("_ResponseT_co", bound=special_endpoints.InteractionResponseBuilder, covariant=True)
_MessageResponseBuilderT = typing.Union[
special_endpoints.InteractionDeferredBuilder, special_endpoints.InteractionMessageBuilder
special_endpoints.InteractionDeferredBuilder,
special_endpoints.InteractionMessageBuilder,
special_endpoints.InteractionPremiumRequiredBuilder,
]
_ModalOrMessageResponseBuilder = typing.Union[_MessageResponseBuilderT, special_endpoints.InteractionModalBuilder]

Expand Down
Loading
Loading