Skip to content

Commit 10ca030

Browse files
committed
Disallow any concurrent voice connections
1 parent 043683f commit 10ca030

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

discord/abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2963,7 +2963,7 @@ async def connect(
29632963
connectable = _channel or self
29642964
channel = await connectable._get_channel()
29652965

2966-
if state._get_voice_client(key_id):
2966+
if state._has_voice_client():
29672967
raise ClientException('Already connected to a voice channel')
29682968

29692969
voice: T = cls(state.client, channel)

discord/state.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,9 @@ def _update_voice_state(
12731273
def _voice_state_for(self, user_id: int) -> Optional[VoiceState]:
12741274
return self._voice_states.get(user_id)
12751275

1276+
def _has_voice_client(self) -> bool:
1277+
return bool(self._voice_clients)
1278+
12761279
def _get_voice_client(self, guild_id: Optional[int]) -> Optional[VoiceProtocol]:
12771280
# The keys of self._voice_clients are ints
12781281
return self._voice_clients.get(guild_id) # type: ignore

0 commit comments

Comments
 (0)