Implement voice region changing for voice channels
This commit is contained in:
parent
3576e2ee01
commit
6524869ddd
@ -257,6 +257,13 @@ class GuildChannel:
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
rtc_region = options.pop('rtc_region')
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
options['rtc_region'] = None if rtc_region is None else str(rtc_region)
|
||||||
|
|
||||||
lock_permissions = options.pop('sync_permissions', False)
|
lock_permissions = options.pop('sync_permissions', False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -29,7 +29,7 @@ import asyncio
|
|||||||
|
|
||||||
import discord.abc
|
import discord.abc
|
||||||
from .permissions import Permissions
|
from .permissions import Permissions
|
||||||
from .enums import ChannelType, try_enum
|
from .enums import ChannelType, try_enum, VoiceRegion
|
||||||
from .mixins import Hashable
|
from .mixins import Hashable
|
||||||
from . import utils
|
from . import utils
|
||||||
from .asset import Asset
|
from .asset import Asset
|
||||||
@ -575,10 +575,16 @@ class VoiceChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable):
|
|||||||
The channel's preferred audio bitrate in bits per second.
|
The channel's preferred audio bitrate in bits per second.
|
||||||
user_limit: :class:`int`
|
user_limit: :class:`int`
|
||||||
The channel's limit for number of members that can be in a voice channel.
|
The channel's limit for number of members that can be in a voice channel.
|
||||||
|
rtc_region: Optional[:class:`VoiceRegion`]
|
||||||
|
The region for the voice channel's voice communication.
|
||||||
|
A value of ``None`` indicates automatic voice region detection.
|
||||||
|
|
||||||
|
.. versionadded:: 1.7
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ('name', 'id', 'guild', 'bitrate', 'user_limit',
|
__slots__ = ('name', 'id', 'guild', 'bitrate', 'user_limit',
|
||||||
'_state', 'position', '_overwrites', 'category_id')
|
'_state', 'position', '_overwrites', 'category_id',
|
||||||
|
'rtc_region')
|
||||||
|
|
||||||
def __init__(self, *, state, guild, data):
|
def __init__(self, *, state, guild, data):
|
||||||
self._state = state
|
self._state = state
|
||||||
@ -589,6 +595,7 @@ class VoiceChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable):
|
|||||||
attrs = [
|
attrs = [
|
||||||
('id', self.id),
|
('id', self.id),
|
||||||
('name', self.name),
|
('name', self.name),
|
||||||
|
('rtc_region', self.rtc_region),
|
||||||
('position', self.position),
|
('position', self.position),
|
||||||
('bitrate', self.bitrate),
|
('bitrate', self.bitrate),
|
||||||
('user_limit', self.user_limit),
|
('user_limit', self.user_limit),
|
||||||
@ -610,6 +617,9 @@ class VoiceChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable):
|
|||||||
def _update(self, guild, data):
|
def _update(self, guild, data):
|
||||||
self.guild = guild
|
self.guild = guild
|
||||||
self.name = data['name']
|
self.name = data['name']
|
||||||
|
self.rtc_region = data.get('rtc_region')
|
||||||
|
if self.rtc_region:
|
||||||
|
self.rtc_region = try_enum(VoiceRegion, self.rtc_region)
|
||||||
self.category_id = utils._get_as_snowflake(data, 'parent_id')
|
self.category_id = utils._get_as_snowflake(data, 'parent_id')
|
||||||
self.position = data['position']
|
self.position = data['position']
|
||||||
self.bitrate = data.get('bitrate')
|
self.bitrate = data.get('bitrate')
|
||||||
@ -700,6 +710,11 @@ class VoiceChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable):
|
|||||||
overwrites: :class:`dict`
|
overwrites: :class:`dict`
|
||||||
A :class:`dict` of target (either a role or a member) to
|
A :class:`dict` of target (either a role or a member) to
|
||||||
:class:`PermissionOverwrite` to apply to the channel.
|
:class:`PermissionOverwrite` to apply to the channel.
|
||||||
|
rtc_region: Optional[:class:`VoiceRegion`]
|
||||||
|
The new region for the voice channel's voice communication.
|
||||||
|
A value of ``None`` indicates automatic voice region detection.
|
||||||
|
|
||||||
|
.. versionadded:: 1.7
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
------
|
------
|
||||||
|
@ -844,6 +844,13 @@ class Guild(Hashable):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
rtc_region = options.pop('rtc_region')
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
options['rtc_region'] = None if rtc_region is None else str(rtc_region)
|
||||||
|
|
||||||
parent_id = category.id if category else None
|
parent_id = category.id if category else None
|
||||||
return self._state.http.create_channel(self.id, channel_type.value, name=name, parent_id=parent_id,
|
return self._state.http.create_channel(self.id, channel_type.value, name=name, parent_id=parent_id,
|
||||||
permission_overwrites=perms, **options)
|
permission_overwrites=perms, **options)
|
||||||
|
@ -584,11 +584,10 @@ class HTTPClient:
|
|||||||
r = Route('PATCH', '/channels/{channel_id}', channel_id=channel_id)
|
r = Route('PATCH', '/channels/{channel_id}', channel_id=channel_id)
|
||||||
valid_keys = ('name', 'parent_id', 'topic', 'bitrate', 'nsfw',
|
valid_keys = ('name', 'parent_id', 'topic', 'bitrate', 'nsfw',
|
||||||
'user_limit', 'position', 'permission_overwrites', 'rate_limit_per_user',
|
'user_limit', 'position', 'permission_overwrites', 'rate_limit_per_user',
|
||||||
'type')
|
'type', 'rtc_region')
|
||||||
payload = {
|
payload = {
|
||||||
k: v for k, v in options.items() if k in valid_keys
|
k: v for k, v in options.items() if k in valid_keys
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.request(r, reason=reason, json=payload)
|
return self.request(r, reason=reason, json=payload)
|
||||||
|
|
||||||
def bulk_channel_update(self, guild_id, data, *, reason=None):
|
def bulk_channel_update(self, guild_id, data, *, reason=None):
|
||||||
@ -601,7 +600,8 @@ class HTTPClient:
|
|||||||
}
|
}
|
||||||
|
|
||||||
valid_keys = ('name', 'parent_id', 'topic', 'bitrate', 'nsfw',
|
valid_keys = ('name', 'parent_id', 'topic', 'bitrate', 'nsfw',
|
||||||
'user_limit', 'position', 'permission_overwrites', 'rate_limit_per_user')
|
'user_limit', 'position', 'permission_overwrites', 'rate_limit_per_user',
|
||||||
|
'rtc_region')
|
||||||
payload.update({
|
payload.update({
|
||||||
k: v for k, v in options.items() if k in valid_keys and v is not None
|
k: v for k, v in options.items() if k in valid_keys and v is not None
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user