|
49 | 49 | from .guild import Guild
|
50 | 50 | from .http import HTTPClient
|
51 | 51 | from .invite import Invite
|
52 |
| -from .iterators import GuildIterator |
| 52 | +from .iterators import EntitlementIterator, GuildIterator |
53 | 53 | from .mentions import AllowedMentions
|
54 | 54 | from .monetization import SKU, Entitlement
|
55 | 55 | from .object import Object
|
@@ -2043,17 +2043,71 @@ async def fetch_skus(self) -> list[SKU]:
|
2043 | 2043 | data = await self._connection.http.list_skus(self.application_id)
|
2044 | 2044 | return [SKU(data=s) for s in data]
|
2045 | 2045 |
|
2046 |
| - async def fetch_entitlements(self) -> list[Entitlement]: |
| 2046 | + async def fetch_entitlements( |
| 2047 | + self, |
| 2048 | + user: Snowflake | None = None, |
| 2049 | + skus: list[Snowflake] | None = None, |
| 2050 | + before: SnowflakeTime | None = None, |
| 2051 | + after: SnowflakeTime | None = None, |
| 2052 | + limit: int | None = 100, |
| 2053 | + guild: Snowflake | None = None, |
| 2054 | + exclude_ended: bool = False, |
| 2055 | + ) -> EntitlementIterator: |
2047 | 2056 | """|coro|
|
2048 | 2057 |
|
2049 | 2058 | Fetches the bot's entitlements.
|
2050 | 2059 |
|
2051 | 2060 | .. versionadded:: 2.5
|
2052 | 2061 |
|
| 2062 | + Parameters |
| 2063 | + ---------- |
| 2064 | + user: :class:`.abc.Snowflake` | None |
| 2065 | + Limit the fetched entitlements to entitlements owned by this user. |
| 2066 | + skus: list[:class:`.abc.Snowflake`] | None |
| 2067 | + Limit the fetched entitlements to entitlements that are for these SKUs. |
| 2068 | + before: :class:`.abc.Snowflake` | :class:`datetime.datetime` | None |
| 2069 | + Retrieves guilds before this date or object. |
| 2070 | + If a datetime is provided, it is recommended to use a UTC-aware datetime. |
| 2071 | + If the datetime is naive, it is assumed to be local time. |
| 2072 | + after: :class:`.abc.Snowflake` | :class:`datetime.datetime` | None |
| 2073 | + Retrieve guilds after this date or object. |
| 2074 | + If a datetime is provided, it is recommended to use a UTC-aware datetime. |
| 2075 | + If the datetime is naive, it is assumed to be local time. |
| 2076 | + limit: Optional[:class:`int`] |
| 2077 | + The number of entitlements to retrieve. |
| 2078 | + If ``None``, retrieves every entitlement, which may be slow. |
| 2079 | + Defaults to ``100``. |
| 2080 | + guild: :class:`.abc.Snowflake` | None |
| 2081 | + Limit the fetched entitlements to entitlements owned by this guild. |
| 2082 | + exclude_ended: :class:`bool` |
| 2083 | + Whether to limit the fetched entitlements to those that have not ended. |
| 2084 | + Defaults to ``False``. |
| 2085 | +
|
2053 | 2086 | Returns
|
2054 | 2087 | -------
|
2055 | 2088 | List[:class:`.Entitlement`]
|
2056 |
| - The bot's entitlements. |
| 2089 | + The application's entitlements. |
| 2090 | +
|
| 2091 | + Raises |
| 2092 | + ------ |
| 2093 | + :exc:`HTTPException` |
| 2094 | + Retrieving the entitlements failed. |
| 2095 | + """ |
| 2096 | + return EntitlementIterator( |
| 2097 | + self._connection, |
| 2098 | + user_id=user.id, |
| 2099 | + sku_ids=[sku.id for sku in skus], |
| 2100 | + before=before, |
| 2101 | + after=after, |
| 2102 | + limit=limit, |
| 2103 | + guild_id=guild.id, |
| 2104 | + exclude_ended=exclude_ended, |
| 2105 | + ) |
| 2106 | + |
| 2107 | + @property |
| 2108 | + def store_url(self) -> str: |
| 2109 | + """:class:`str`: The URL that leads to the application's store page for monetization. |
| 2110 | +
|
| 2111 | + .. versionadded:: 2.6 |
2057 | 2112 | """
|
2058 |
| - data = await self._connection.http.list_entitlements(self.application_id) |
2059 |
| - return [Entitlement(data=e, state=self._connection) for e in data] |
| 2113 | + return f"https://discord.com/application-directory/{self.application_id}/store" |
0 commit comments