Skip to content

Commit 2b97855

Browse files
committed
fix: This too
1 parent 947e233 commit 2b97855

3 files changed

Lines changed: 37 additions & 39 deletions

File tree

discord/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@
7070
from .threads import Thread
7171
from .ui.view import BaseView
7272
from .user import ClientUser, User
73-
from .utils import _D, _FETCHABLE, MISSING
74-
from .voice.utils.dependencies import warn_if_voice_dependencies_missing
73+
from .utils import _D, _FETCHABLE, MISSING, warn_if_voice_dependencies_missing
7574
from .webhook import Webhook
7675
from .widget import Widget
7776

@@ -93,7 +92,6 @@
9392

9493
Coro = TypeVar("Coro", bound=Callable[..., Coroutine[Any, Any, Any]])
9594

96-
9795
_log = logging.getLogger(__name__)
9896

9997

discord/utils.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
else:
9494
HAS_MSGSPEC = True
9595

96-
9796
__all__ = (
9897
"parse_time",
9998
"warn_deprecated",
@@ -140,7 +139,6 @@
140139
)
141140
EMOJIS_MAP = {}
142141

143-
144142
UNICODE_EMOJIS = set(EMOJIS_MAP.values())
145143

146144

@@ -176,7 +174,6 @@ class _RequestLike(Protocol):
176174
AutocompleteContext = Any
177175
OptionChoice = Any
178176

179-
180177
T = TypeVar("T")
181178
T_co = TypeVar("T_co", covariant=True)
182179
_Iter = Union[Iterator[T], AsyncIterator[T]]
@@ -1632,3 +1629,39 @@ def users_to_csv(users: Iterable[Snowflake]) -> io.BytesIO:
16321629
A file-like object containing the CSV data.
16331630
"""
16341631
return io.BytesIO("\n".join(map(lambda u: str(u.id), users)).encode("utf-8"))
1632+
1633+
1634+
voice_dependency_warning_emitted = False
1635+
1636+
1637+
def get_missing_voice_dependencies() -> tuple[str, ...]:
1638+
missing: list[str] = []
1639+
try:
1640+
import nacl.secret
1641+
import nacl.utils
1642+
except ImportError:
1643+
missing.append("PyNaCl")
1644+
1645+
try:
1646+
import davey
1647+
except ImportError:
1648+
missing.append("davey")
1649+
return tuple(missing)
1650+
1651+
1652+
def warn_if_voice_dependencies_missing() -> None:
1653+
global voice_dependency_warning_emitted
1654+
if voice_dependency_warning_emitted:
1655+
return
1656+
1657+
missing = get_missing_voice_dependencies()
1658+
if not missing:
1659+
return
1660+
1661+
voice_dependency_warning_emitted = True
1662+
deps = ", ".join(missing)
1663+
_log.warning(
1664+
"%s %s not installed, voice will NOT be supported",
1665+
deps,
1666+
"is" if len(missing) == 1 else "are",
1667+
)

discord/voice/utils/dependencies.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
DEALINGS IN THE SOFTWARE.
2323
"""
2424

25-
import logging
26-
2725
try:
2826
import davey
2927
except ImportError:
@@ -40,34 +38,3 @@
4038
HAS_NACL = False
4139
else:
4240
HAS_NACL = True
43-
44-
VOICE_DEPENDENCY_WARNING_EMITTED = False
45-
46-
_log = logging.getLogger("discord.client")
47-
48-
49-
def get_missing_voice_dependencies() -> tuple[str, ...]:
50-
missing: list[str] = []
51-
if not HAS_NACL:
52-
missing.append("PyNaCl")
53-
if not HAS_DAVEY:
54-
missing.append("davey")
55-
return tuple(missing)
56-
57-
58-
def warn_if_voice_dependencies_missing() -> None:
59-
global VOICE_DEPENDENCY_WARNING_EMITTED
60-
if VOICE_DEPENDENCY_WARNING_EMITTED:
61-
return
62-
63-
missing = get_missing_voice_dependencies()
64-
if not missing:
65-
return
66-
67-
VOICE_DEPENDENCY_WARNING_EMITTED = True
68-
deps = ", ".join(missing)
69-
_log.warning(
70-
"%s %s not installed, voice will NOT be supported",
71-
deps,
72-
"is" if len(missing) == 1 else "are",
73-
)

0 commit comments

Comments
 (0)