Skip to content

Commit 6006042

Browse files
committed
first commit at partial objs
1 parent f15035b commit 6006042

File tree

7 files changed

+475
-302
lines changed

7 files changed

+475
-302
lines changed

discord/appinfo.py

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@
3636
from .app.state import ConnectionState
3737
from .types.appinfo import AppInfo as AppInfoPayload
3838
from .types.appinfo import AppInstallParams as AppInstallParamsPayload
39-
from .types.appinfo import PartialAppInfo as PartialAppInfoPayload
4039
from .types.appinfo import Team as TeamPayload
4140
from .user import User
4241

4342
__all__ = (
4443
"AppInfo",
45-
"PartialAppInfo",
4644
"AppInstallParams",
4745
)
4846

@@ -268,69 +266,6 @@ def summary(self) -> str | None:
268266
return self._summary
269267

270268

271-
class PartialAppInfo:
272-
"""Represents a partial AppInfo given by :func:`~discord.abc.GuildChannel.create_invite`
273-
274-
.. versionadded:: 2.0
275-
276-
Attributes
277-
----------
278-
id: :class:`int`
279-
The application ID.
280-
name: :class:`str`
281-
The application name.
282-
description: :class:`str`
283-
The application description.
284-
rpc_origins: Optional[List[:class:`str`]]
285-
A list of RPC origin URLs, if RPC is enabled.
286-
summary: :class:`str`
287-
If this application is a game sold on Discord,
288-
this field will be the summary field for the store page of its primary SKU.
289-
verify_key: :class:`str`
290-
The hex encoded key for verification in interactions and the
291-
GameSDK's `GetTicket <https://discord.com/developers/docs/game-sdk/applications#getticket>`_.
292-
terms_of_service_url: Optional[:class:`str`]
293-
The application's terms of service URL, if set.
294-
privacy_policy_url: Optional[:class:`str`]
295-
The application's privacy policy URL, if set.
296-
"""
297-
298-
__slots__ = (
299-
"_state",
300-
"id",
301-
"name",
302-
"description",
303-
"rpc_origins",
304-
"summary",
305-
"verify_key",
306-
"terms_of_service_url",
307-
"privacy_policy_url",
308-
"_icon",
309-
)
310-
311-
def __init__(self, *, state: ConnectionState, data: PartialAppInfoPayload):
312-
self._state: ConnectionState = state
313-
self.id: int = int(data["id"])
314-
self.name: str = data["name"]
315-
self._icon: str | None = data.get("icon")
316-
self.description: str = data["description"]
317-
self.rpc_origins: list[str] | None = data.get("rpc_origins")
318-
self.summary: str = data["summary"]
319-
self.verify_key: str = data["verify_key"]
320-
self.terms_of_service_url: str | None = data.get("terms_of_service_url")
321-
self.privacy_policy_url: str | None = data.get("privacy_policy_url")
322-
323-
def __repr__(self) -> str:
324-
return f"<{self.__class__.__name__} id={self.id} name={self.name!r} description={self.description!r}>"
325-
326-
@property
327-
def icon(self) -> Asset | None:
328-
"""Retrieves the application's icon asset, if any."""
329-
if self._icon is None:
330-
return None
331-
return Asset._from_icon(self._state, self.id, self._icon, path="app")
332-
333-
334269
class AppInstallParams:
335270
"""Represents the settings for the custom authorization URL of an application.
336271

discord/errors.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"ApplicationCommandError",
6565
"CheckFailure",
6666
"ApplicationCommandInvokeError",
67+
"MissingApplicationID",
6768
)
6869

6970

@@ -404,3 +405,14 @@ class ApplicationCommandInvokeError(ApplicationCommandError):
404405
def __init__(self, e: Exception) -> None:
405406
self.original: Exception = e
406407
super().__init__(f"Application Command raised an exception: {e.__class__.__name__}: {e}")
408+
409+
410+
class MissingApplicationID(ClientException):
411+
"""Exception raised when you try to perform an operation that involves the application
412+
ID, but this has not yet been set.
413+
414+
This inherits from :exc:`ClientException`
415+
"""
416+
417+
def __init__(self) -> None:
418+
super().__init__("The application ID has not yet been set")

discord/iterators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,8 @@ def __init__(
957957
state,
958958
user_id: int | None = None,
959959
sku_ids: list[int] | None = None,
960-
before: datetime.datetime | Object | None = None,
961-
after: datetime.datetime | Object | None = None,
960+
before: datetime.datetime | Snowflake | None = None,
961+
after: datetime.datetime | Snowflake | None = None,
962962
limit: int | None = None,
963963
guild_id: int | None = None,
964964
exclude_ended: bool | None = None,

discord/partials/__init__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2021-present Pycord Development
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a
7+
copy of this software and associated documentation files (the "Software"),
8+
to deal in the Software without restriction, including without limitation
9+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10+
and/or sell copies of the Software, and to permit persons to whom the
11+
Software is furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22+
DEALINGS IN THE SOFTWARE.
23+
"""
24+
25+
from .appinfo import PartialAppInfo
26+
from .user import PartialUser
27+
28+
__all__ = (
29+
"PartialAppInfo",
30+
"PartialUser",
31+
)

discord/partials/appinfo.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
"""
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2021-present Pycord Development
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a
7+
copy of this software and associated documentation files (the "Software"),
8+
to deal in the Software without restriction, including without limitation
9+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10+
and/or sell copies of the Software, and to permit persons to whom the
11+
Software is furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22+
DEALINGS IN THE SOFTWARE.
23+
"""
24+
from __future__ import annotations
25+
26+
from typing import TYPE_CHECKING
27+
28+
if TYPE_CHECKING:
29+
from ..app.state import ConnectionState
30+
from ..types.appinfo import PartialAppInfo as PartialAppInfoPayload
31+
from ..asset import Asset
32+
33+
34+
class PartialAppInfo:
35+
"""Represents a partial AppInfo given by :func:`~discord.abc.GuildChannel.create_invite`
36+
37+
.. versionadded:: 2.0
38+
39+
Attributes
40+
----------
41+
id: :class:`int`
42+
The application ID.
43+
name: :class:`str`
44+
The application name.
45+
description: :class:`str`
46+
The application description.
47+
rpc_origins: Optional[List[:class:`str`]]
48+
A list of RPC origin URLs, if RPC is enabled.
49+
summary: :class:`str`
50+
If this application is a game sold on Discord,
51+
this field will be the summary field for the store page of its primary SKU.
52+
verify_key: :class:`str`
53+
The hex encoded key for verification in interactions and the
54+
GameSDK's `GetTicket <https://discord.com/developers/docs/game-sdk/applications#getticket>`_.
55+
terms_of_service_url: Optional[:class:`str`]
56+
The application's terms of service URL, if set.
57+
privacy_policy_url: Optional[:class:`str`]
58+
The application's privacy policy URL, if set.
59+
"""
60+
61+
__slots__ = (
62+
"_state",
63+
"id",
64+
"name",
65+
"description",
66+
"rpc_origins",
67+
"summary",
68+
"verify_key",
69+
"terms_of_service_url",
70+
"privacy_policy_url",
71+
"_icon",
72+
)
73+
74+
def __init__(self, *, state: ConnectionState, data: PartialAppInfoPayload):
75+
self._state: ConnectionState = state
76+
self.id: int = int(data["id"])
77+
self.name: str = data["name"]
78+
self._icon: str | None = data.get("icon")
79+
self.description: str = data["description"]
80+
self.rpc_origins: list[str] | None = data.get("rpc_origins")
81+
self.summary: str = data["summary"]
82+
self.verify_key: str = data["verify_key"]
83+
self.terms_of_service_url: str | None = data.get("terms_of_service_url")
84+
self.privacy_policy_url: str | None = data.get("privacy_policy_url")
85+
86+
def __repr__(self) -> str:
87+
return f"<{self.__class__.__name__} id={self.id} name={self.name!r} description={self.description!r}>"
88+
89+
@property
90+
def icon(self) -> Asset | None:
91+
"""Retrieves the application's icon asset, if any."""
92+
if self._icon is None:
93+
return None
94+
return Asset._from_icon(self._state, self.id, self._icon, path="app")

0 commit comments

Comments
 (0)