Skip to content

Commit ab4db06

Browse files
committed
Updated PyCord to fix voice issues
1 parent 8b686ea commit ab4db06

33 files changed

+934
-321
lines changed

Patches/4_version.patch

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
diff --git a/src/_discord/_version.py b/src/_discord/_version.py
2-
index 70b66e8..87093fa 100644
2+
index c58c8ba..3761f0f 100644
33
--- a/src/_discord/_version.py
44
+++ b/src/_discord/_version.py
5-
@@ -25,9 +25,7 @@ DEALINGS IN THE SOFTWARE.
6-
from __future__ import annotations
7-
8-
import re
9-
-import warnings
10-
from datetime import date
11-
-from importlib.metadata import PackageNotFoundError, version
12-
13-
__all__ = ("__version__", "VersionInfo", "version_info")
14-
15-
@@ -35,23 +33,7 @@ from typing import Literal, NamedTuple
5+
@@ -37,25 +37,7 @@ from typing import Literal, NamedTuple
166

177
from .utils import deprecated
188

@@ -28,12 +18,14 @@ index 70b66e8..87093fa 100644
2818
- # setuptools_scm is not installed
2919
- __version__ = "0.0.0"
3020
- warnings.warn(
31-
- "Package is not installed, and setuptools_scm is not installed. "
32-
- f"As a fallback, {__name__}.__version__ will be set to {__version__}",
21+
- (
22+
- "Package is not installed, and setuptools_scm is not installed. "
23+
- f"As a fallback, {__name__}.__version__ will be set to {__version__}"
24+
- ),
3325
- RuntimeWarning,
3426
- stacklevel=2,
3527
- )
36-
+__version__ = "2.3"
28+
+__version__ = "2.4.1"
3729

3830

39-
class VersionInfo(NamedTuple):
31+
class AdvancedVersionInfo(TypedDict):

src/_discord/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from . import abc, opus, sinks, ui, utils
2828
from .activity import *
2929
from .appinfo import *
30+
from .application_role_connection import *
3031
from .asset import *
3132
from .audit_logs import *
3233
from .automod import *

src/_discord/_version.py

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,70 @@
2424
"""
2525
from __future__ import annotations
2626

27+
import datetime
2728
import re
28-
from datetime import date
29+
import warnings
30+
from importlib.metadata import PackageNotFoundError, version
31+
32+
from ._typed_dict import TypedDict
2933

3034
__all__ = ("__version__", "VersionInfo", "version_info")
3135

3236
from typing import Literal, NamedTuple
3337

3438
from .utils import deprecated
3539

36-
__version__ = "2.3"
40+
__version__ = "2.4.1"
41+
42+
43+
class AdvancedVersionInfo(TypedDict):
44+
serial: int
45+
build: int | None
46+
commit: str | None
47+
date: datetime.date | None
3748

3849

3950
class VersionInfo(NamedTuple):
4051
major: int
4152
minor: int
4253
micro: int
43-
release_level: Literal["alpha", "beta", "candidate", "final"]
44-
serial: int
45-
build: int | None = None
46-
commit: str | None = None
47-
date: date | None = None
54+
releaselevel: Literal["alpha", "beta", "candidate", "final"]
55+
56+
# We can't set instance attributes on a NamedTuple, so we have to use a
57+
# global variable to store the advanced version info.
58+
@property
59+
def advanced(self) -> AdvancedVersionInfo:
60+
return _advanced
61+
62+
@advanced.setter
63+
def advanced(self, value: object) -> None:
64+
global _advanced
65+
_advanced = value
66+
67+
@property
68+
@deprecated("releaselevel", "2.4")
69+
def release_level(self) -> Literal["alpha", "beta", "candidate", "final"]:
70+
return self.releaselevel
4871

4972
@property
50-
@deprecated("release_level", "2.3")
51-
def releaselevel(self) -> Literal["alpha", "beta", "candidate", "final"]:
52-
return self.release_level
73+
@deprecated('.advanced["serial"]', "2.4")
74+
def serial(self) -> int:
75+
return self.advanced["serial"]
76+
77+
@property
78+
@deprecated('.advanced["build"]', "2.4")
79+
def build(self) -> int | None:
80+
return self.advanced["build"]
81+
82+
@property
83+
@deprecated('.advanced["commit"]', "2.4")
84+
def commit(self) -> str | None:
85+
return self.advanced["commit"]
86+
87+
@property
88+
@deprecated('.advanced["date"]', "2.4")
89+
def date(self) -> datetime.date | None:
90+
return self.advanced["date"]
5391

5492

5593
version_regex = re.compile(
@@ -77,7 +115,7 @@ def releaselevel(self) -> Literal["alpha", "beta", "candidate", "final"]:
77115
raise RuntimeError("Invalid release level")
78116

79117
if (raw_date := raw_info["date"] or raw_info["date1"]) is not None:
80-
date_info = date(
118+
date_info = datetime.date(
81119
int(raw_date[:4]),
82120
int(raw_date[4:6]),
83121
int(raw_date[6:]),
@@ -89,7 +127,10 @@ def releaselevel(self) -> Literal["alpha", "beta", "candidate", "final"]:
89127
major=int(raw_info["major"] or 0) or None,
90128
minor=int(raw_info["minor"] or 0) or None,
91129
micro=int(raw_info["patch"] or 0) or None,
92-
release_level=level_info,
130+
releaselevel=level_info,
131+
)
132+
133+
_advanced = AdvancedVersionInfo(
93134
serial=raw_info["serial"],
94135
build=int(raw_info["build"] or 0) or None,
95136
commit=raw_info["commit"],

src/_discord/abc.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,11 @@ async def _edit(
478478
"allow": allow.value,
479479
"deny": deny.value,
480480
"id": target.id,
481-
"type": _Overwrites.ROLE
482-
if isinstance(target, Role)
483-
else _Overwrites.MEMBER,
481+
"type": (
482+
_Overwrites.ROLE
483+
if isinstance(target, Role)
484+
else _Overwrites.MEMBER
485+
),
484486
}
485487

486488
perms.append(payload)
@@ -1321,6 +1323,7 @@ async def send(
13211323
mention_author: bool = ...,
13221324
view: View = ...,
13231325
suppress: bool = ...,
1326+
silent: bool = ...,
13241327
) -> Message:
13251328
...
13261329

@@ -1340,6 +1343,7 @@ async def send(
13401343
mention_author: bool = ...,
13411344
view: View = ...,
13421345
suppress: bool = ...,
1346+
silent: bool = ...,
13431347
) -> Message:
13441348
...
13451349

@@ -1359,6 +1363,7 @@ async def send(
13591363
mention_author: bool = ...,
13601364
view: View = ...,
13611365
suppress: bool = ...,
1366+
silent: bool = ...,
13621367
) -> Message:
13631368
...
13641369

@@ -1378,6 +1383,7 @@ async def send(
13781383
mention_author: bool = ...,
13791384
view: View = ...,
13801385
suppress: bool = ...,
1386+
silent: bool = ...,
13811387
) -> Message:
13821388
...
13831389

@@ -1398,6 +1404,7 @@ async def send(
13981404
mention_author=None,
13991405
view=None,
14001406
suppress=None,
1407+
silent=None,
14011408
):
14021409
"""|coro|
14031410
@@ -1471,6 +1478,10 @@ async def send(
14711478
.. versionadded:: 2.0
14721479
suppress: :class:`bool`
14731480
Whether to suppress embeds for the message.
1481+
slient: :class:`bool`
1482+
Whether to suppress push and desktop notifications for the message.
1483+
1484+
.. versionadded:: 2.4
14741485
14751486
Returns
14761487
-------
@@ -1510,11 +1521,10 @@ async def send(
15101521
)
15111522
embeds = [embed.to_dict() for embed in embeds]
15121523

1513-
flags = (
1514-
MessageFlags.suppress_embeds.flag
1515-
if suppress
1516-
else MessageFlags.DEFAULT_VALUE
1517-
)
1524+
flags = MessageFlags(
1525+
suppress_embeds=bool(suppress),
1526+
suppress_notifications=bool(silent),
1527+
).value
15181528

15191529
if stickers is not None:
15201530
stickers = [sticker.id for sticker in stickers]
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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 __future__ import annotations
26+
27+
from typing import TYPE_CHECKING
28+
29+
from .enums import ApplicationRoleConnectionMetadataType, try_enum
30+
from .utils import MISSING
31+
32+
if TYPE_CHECKING:
33+
from .types.application_role_connection import (
34+
ApplicationRoleConnectionMetadata as ApplicationRoleConnectionMetadataPayload,
35+
)
36+
37+
__all__ = ("ApplicationRoleConnectionMetadata",)
38+
39+
40+
class ApplicationRoleConnectionMetadata:
41+
r"""Represents role connection metadata for a Discord application.
42+
43+
.. versionadded:: 2.4
44+
45+
Parameters
46+
----------
47+
type: :class:`ApplicationRoleConnectionMetadataType`
48+
The type of metadata value.
49+
key: :class:`str`
50+
The key for this metadata field.
51+
May only be the ``a-z``, ``0-9``, or ``_`` characters, with a maximum of 50 characters.
52+
name: :class:`str`
53+
The name for this metadata field. Maximum 100 characters.
54+
description: :class:`str`
55+
The description for this metadata field. Maximum 200 characters.
56+
name_localizations: Optional[Dict[:class:`str`, :class:`str`]]
57+
The name localizations for this metadata field. The values of this should be ``"locale": "name"``.
58+
See `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.
59+
description_localizations: Optional[Dict[:class:`str`, :class:`str`]]
60+
The description localizations for this metadata field. The values of this should be ``"locale": "name"``.
61+
See `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.
62+
"""
63+
64+
__slots__ = (
65+
"type",
66+
"key",
67+
"name",
68+
"description",
69+
"name_localizations",
70+
"description_localizations",
71+
)
72+
73+
def __init__(
74+
self,
75+
*,
76+
type: ApplicationRoleConnectionMetadataType,
77+
key: str,
78+
name: str,
79+
description: str,
80+
name_localizations: dict[str, str] = MISSING,
81+
description_localizations: dict[str, str] = MISSING,
82+
):
83+
self.type: ApplicationRoleConnectionMetadataType = type
84+
self.key: str = key
85+
self.name: str = name
86+
self.name_localizations: dict[str, str] = name_localizations
87+
self.description: str = description
88+
self.description_localizations: dict[str, str] = description_localizations
89+
90+
def __repr__(self):
91+
return (
92+
"<ApplicationRoleConnectionMetadata "
93+
f"type={self.type!r} "
94+
f"key={self.key!r} "
95+
f"name={self.name!r} "
96+
f"description={self.description!r} "
97+
f"name_localizations={self.name_localizations!r} "
98+
f"description_localizations={self.description_localizations!r}>"
99+
)
100+
101+
def __str__(self):
102+
return self.name
103+
104+
@classmethod
105+
def from_dict(
106+
cls, data: ApplicationRoleConnectionMetadataPayload
107+
) -> ApplicationRoleConnectionMetadata:
108+
return cls(
109+
type=try_enum(ApplicationRoleConnectionMetadataType, data["type"]),
110+
key=data["key"],
111+
name=data["name"],
112+
description=data["description"],
113+
name_localizations=data.get("name_localizations"),
114+
description_localizations=data.get("description_localizations"),
115+
)
116+
117+
def to_dict(self) -> ApplicationRoleConnectionMetadataPayload:
118+
data = {
119+
"type": self.type.value,
120+
"key": self.key,
121+
"name": self.name,
122+
"description": self.description,
123+
}
124+
if self.name_localizations is not MISSING:
125+
data["name_localizations"] = self.name_localizations
126+
if self.description_localizations is not MISSING:
127+
data["description_localizations"] = self.description_localizations
128+
return data

0 commit comments

Comments
 (0)