Skip to content

Commit

Permalink
style(pre-commit): auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Dec 1, 2023
1 parent 3b78bb5 commit a1aa579
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
from .invite import Invite
from .iterators import GuildIterator
from .mentions import AllowedMentions
from .monetization import Entitlement, SKU
from .monetization import SKU, Entitlement
from .object import Object
from .stage_instance import StageInstance
from .state import ConnectionState
Expand Down Expand Up @@ -2016,7 +2016,7 @@ async def fetch_skus(self) -> list[SKU]:
"""
data = await self._connection.http.list_skus(self.application_id)
return [SKU(data=s, state=self._connection) for s in data]

async def fetch_entitlements(self) -> list[Entitlement]:
"""|coro|
Expand Down
2 changes: 1 addition & 1 deletion discord/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ class InteractionResponseType(Enum):
message_update = 7 # for components
auto_complete_result = 8 # for autocomplete interactions
modal = 9 # for modal dialogs
premium_required = 10
premium_required = 10


class VideoQualityMode(Enum):
Expand Down
4 changes: 2 additions & 2 deletions discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2896,7 +2896,7 @@ def list_skus(
application_id=application_id,
)
return self.request(r)

def list_entitlements(
self,
application_id: Snowflake,
Expand All @@ -2919,7 +2919,7 @@ def create_test_entitlement(
application_id=application_id,
)
return self.request(r, json=payload)

def delete_test_entitlement(
self,
application_id: Snowflake,
Expand Down
22 changes: 11 additions & 11 deletions discord/monetization.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,19 @@

from __future__ import annotations

from typing import (
TYPE_CHECKING,
)
from typing import TYPE_CHECKING

from .enums import SKUType, EntitlementType, try_enum
from .enums import EntitlementType, SKUType, try_enum
from .flags import SKUFlags
from .utils import _get_as_snowflake, parse_time, MISSING
from .mixins import Hashable
from .utils import MISSING, _get_as_snowflake, parse_time

if TYPE_CHECKING:
from datetime import datetime

from .types.monetization import (
SKU as SKUPayload,
Entitlement as EntitlementPayload,
)
from .state import ConnectionState
from .types.monetization import SKU as SKUPayload
from .types.monetization import Entitlement as EntitlementPayload


__all__ = (
Expand All @@ -59,6 +55,7 @@ class SKU(Hashable):
"slug",
"flags",
)

def __init__(self, *, data: SKUPayload, state: ConnectionState) -> None:
self._state = state
self.id: int = int(data["id"])
Expand Down Expand Up @@ -90,6 +87,7 @@ class Entitlement(Hashable):
"starts_at",
"ends_at",
)

def __init__(self, *, data: EntitlementPayload, state: ConnectionState) -> None:
self._state = state
self.id: int = int(data["id"])
Expand All @@ -98,7 +96,9 @@ def __init__(self, *, data: EntitlementPayload, state: ConnectionState) -> None:
self.user_id: int | MISSING = _get_as_snowflake(data, "user_id") or MISSING
self.type: EntitlementType = try_enum(EntitlementType, data["type"])
self.deleted: bool = data["deleted"]
self.starts_at: datetime | MISSING = parse_time(data.get("starts_at")) or MISSING
self.starts_at: datetime | MISSING = (
parse_time(data.get("starts_at")) or MISSING
)
self.ends_at: datetime | MISSING = parse_time(data.get("ends_at")) or MISSING

def __repr__(self) -> str:
Expand All @@ -107,7 +107,7 @@ def __repr__(self) -> str:
f"user_id={self.user_id} type={self.type} deleted={self.deleted} "
f"starts_at={self.starts_at} ends_at={self.ends_at}>"
)

async def delete(self) -> None:
"""|coro|
Expand Down
1 change: 0 additions & 1 deletion discord/raw_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,4 +749,3 @@ def __init__(self, data: AuditLogEntryEvent) -> None:
self.extra = data.get("options")
self.changes = data.get("changes")
self.data: AuditLogEntryEvent = data

3 changes: 2 additions & 1 deletion discord/types/monetization.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
EntitlementType = Literal[8]
OwnerType = Literal[1, 2]


class SKU(TypedDict):
id: Snowflake
type: SKUType
Expand All @@ -58,4 +59,4 @@ class Entitlement(TypedDict):
class CreateTestEntitlementPayload(TypedDict):
sku_id: Snowflake
owner_id: Snowflake
owner_type: OwnerType
owner_type: OwnerType
1 change: 0 additions & 1 deletion discord/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,4 +602,3 @@ async def create_test_entitlement(self, sku: discord.abc.Snowflake) -> Entitleme
}
data = await self._state.http.create_test_entitlement(self.id, payload)
return Entitlement(data=data, state=self._state)

2 changes: 1 addition & 1 deletion docs/api/enums.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2330,4 +2330,4 @@ of :class:`enum.Enum`.

.. attribute:: app_subscription

Entitlement was purchased as an app subscription.
Entitlement was purchased as an app subscription.
4 changes: 2 additions & 2 deletions docs/api/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,10 @@ Entitlements
:type entitlement: :class:`Entitlement`

.. function:: on_entitlement_delete(entitlement)

Called when a user's entitlement is deleted.

Entitlements are usually only deleted when Discord issues a refund for a subscription,
Entitlements are usually only deleted when Discord issues a refund for a subscription,
or manually removes an entitlement from a user.

.. note::
Expand Down

0 comments on commit a1aa579

Please sign in to comment.