A fix to the `discord.VoiceRegion`
Since dpy has deprecated VoiceRegion the only way of getting the region is `VoiceChannel.rtc_region`, so you will have to pass the string itself for this.
This commit is contained in:
parent
ac6f92241b
commit
331202ae24
|
|
@ -8,7 +8,7 @@ from typing import Dict, Optional, TYPE_CHECKING
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from discord import Client, VoiceRegion
|
from discord import Client
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ class Node:
|
||||||
identifier: str,
|
identifier: str,
|
||||||
secure: bool = False,
|
secure: bool = False,
|
||||||
heartbeat: int = 30,
|
heartbeat: int = 30,
|
||||||
region: Optional[VoiceRegion] = None,
|
region: Optional[str] = None,
|
||||||
session: Optional[aiohttp.ClientSession] = None,
|
session: Optional[aiohttp.ClientSession] = None,
|
||||||
spotify_client_id: Optional[str] = None,
|
spotify_client_id: Optional[str] = None,
|
||||||
spotify_client_secret: Optional[str] = None,
|
spotify_client_secret: Optional[str] = None,
|
||||||
|
|
@ -79,7 +79,7 @@ class Node:
|
||||||
self._identifier = identifier
|
self._identifier = identifier
|
||||||
self._heartbeat = heartbeat
|
self._heartbeat = heartbeat
|
||||||
self._secure = secure
|
self._secure = secure
|
||||||
self._region: Optional[VoiceRegion] = region
|
self._region: Optional[str] = region
|
||||||
|
|
||||||
|
|
||||||
self._websocket_uri = f"{'wss' if self._secure else 'ws'}://{self._host}:{self._port}"
|
self._websocket_uri = f"{'wss' if self._secure else 'ws'}://{self._host}:{self._port}"
|
||||||
|
|
@ -134,7 +134,7 @@ class Node:
|
||||||
return self._players
|
return self._players
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def region(self) -> Optional[VoiceRegion]:
|
def region(self) -> Optional[str]:
|
||||||
"""Property which returns the VoiceRegion of the node, if one is set"""
|
"""Property which returns the VoiceRegion of the node, if one is set"""
|
||||||
return self._region
|
return self._region
|
||||||
|
|
||||||
|
|
@ -455,7 +455,7 @@ class NodePool:
|
||||||
return len(self._nodes.values())
|
return len(self._nodes.values())
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_best_node(cls, *, algorithm: NodeAlgorithm, voice_region: VoiceRegion = None) -> Node:
|
def get_best_node(cls, *, algorithm: NodeAlgorithm, voice_region: str = None) -> Node:
|
||||||
"""Fetches the best node based on an NodeAlgorithm.
|
"""Fetches the best node based on an NodeAlgorithm.
|
||||||
This option is preferred if you want to choose the best node
|
This option is preferred if you want to choose the best node
|
||||||
from a multi-node setup using either the node's latency
|
from a multi-node setup using either the node's latency
|
||||||
|
|
@ -489,7 +489,7 @@ class NodePool:
|
||||||
if voice_region == None:
|
if voice_region == None:
|
||||||
raise NodeException("You must specify a VoiceRegion in order to use this functionality.")
|
raise NodeException("You must specify a VoiceRegion in order to use this functionality.")
|
||||||
|
|
||||||
nodes = [node for node in available_nodes if node._region is voice_region]
|
nodes = [node for node in available_nodes if node._region == voice_region]
|
||||||
if not nodes:
|
if not nodes:
|
||||||
raise NoNodesAvailable(
|
raise NoNodesAvailable(
|
||||||
f"No nodes for region {voice_region} exist in this pool."
|
f"No nodes for region {voice_region} exist in this pool."
|
||||||
|
|
@ -526,7 +526,7 @@ class NodePool:
|
||||||
identifier: str,
|
identifier: str,
|
||||||
secure: bool = False,
|
secure: bool = False,
|
||||||
heartbeat: int = 30,
|
heartbeat: int = 30,
|
||||||
region: Optional[VoiceRegion] = None,
|
region: Optional[str] = None,
|
||||||
spotify_client_id: Optional[str] = None,
|
spotify_client_id: Optional[str] = None,
|
||||||
spotify_client_secret: Optional[str] = None,
|
spotify_client_secret: Optional[str] = None,
|
||||||
session: Optional[aiohttp.ClientSession] = None,
|
session: Optional[aiohttp.ClientSession] = None,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue