diff --git a/discord/audit_logs.py b/discord/audit_logs.py index da9564881..f956908ab 100644 --- a/discord/audit_logs.py +++ b/discord/audit_logs.py @@ -228,8 +228,6 @@ class AuditLogChanges: 'guild_id': ('guild', _transform_guild_id), 'tags': ('emoji', None), 'default_message_notifications': ('default_notifications', _enum_transformer(enums.NotificationLevel)), - 'region': (None, _enum_transformer(enums.VoiceRegion)), - 'rtc_region': (None, _enum_transformer(enums.VoiceRegion)), 'video_quality_mode': (None, _enum_transformer(enums.VideoQualityMode)), 'privacy_level': (None, _enum_transformer(enums.StagePrivacyLevel)), 'format_type': (None, _enum_transformer(enums.StickerFormatType)), diff --git a/discord/channel.py b/discord/channel.py index 60f05dc97..f79b1b5f6 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -46,7 +46,7 @@ import datetime import discord.abc from .permissions import PermissionOverwrite, Permissions -from .enums import ChannelType, StagePrivacyLevel, try_enum, VoiceRegion, VideoQualityMode +from .enums import ChannelType, StagePrivacyLevel, try_enum, VideoQualityMode from .mixins import Hashable from .object import Object from . import utils @@ -879,8 +879,7 @@ class VocalGuildChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hasha def _update(self, guild: Guild, data: Union[VoiceChannelPayload, StageChannelPayload]) -> None: self.guild = guild self.name: str = data['name'] - rtc = data.get('rtc_region') - self.rtc_region: Optional[VoiceRegion] = try_enum(VoiceRegion, rtc) if rtc is not None else None + self.rtc_region: Optional[str] = data.get('rtc_region') self.video_quality_mode: VideoQualityMode = try_enum(VideoQualityMode, data.get('video_quality_mode', 1)) self.category_id: Optional[int] = utils._get_as_snowflake(data, 'parent_id') self.position: int = data['position'] @@ -978,11 +977,14 @@ class VoiceChannel(VocalGuildChannel): The channel's preferred audio bitrate in bits per second. user_limit: :class:`int` The channel's limit for number of members that can be in a voice channel. - rtc_region: Optional[:class:`VoiceRegion`] + rtc_region: Optional[:class:`str`] The region for the voice channel's voice communication. A value of ``None`` indicates automatic voice region detection. .. versionadded:: 1.7 + + .. versionchanged:: 2.0 + The type of this attribute has changed to :class:`str`. video_quality_mode: :class:`VideoQualityMode` The camera video quality for the voice channel's participants. @@ -1025,7 +1027,7 @@ class VoiceChannel(VocalGuildChannel): sync_permissions: int = ..., category: Optional[CategoryChannel] = ..., overwrites: Mapping[Union[Role, Member], PermissionOverwrite] = ..., - rtc_region: Optional[VoiceRegion] = ..., + rtc_region: Optional[str] = ..., video_quality_mode: VideoQualityMode = ..., reason: Optional[str] = ..., ) -> Optional[VoiceChannel]: @@ -1049,6 +1051,9 @@ class VoiceChannel(VocalGuildChannel): .. versionchanged:: 2.0 Edits are no longer in-place, the newly edited channel is returned instead. + .. versionchanged:: 2.0 + The ``region`` parameter now accepts :class:`str` instead of an enum. + Parameters ---------- name: :class:`str` @@ -1070,7 +1075,7 @@ class VoiceChannel(VocalGuildChannel): overwrites: :class:`Mapping` A :class:`Mapping` of target (either a role or a member) to :class:`PermissionOverwrite` to apply to the channel. - rtc_region: Optional[:class:`VoiceRegion`] + rtc_region: Optional[:class:`str`] The new region for the voice channel's voice communication. A value of ``None`` indicates automatic voice region detection. @@ -1144,7 +1149,7 @@ class StageChannel(VocalGuildChannel): The channel's preferred audio bitrate in bits per second. user_limit: :class:`int` The channel's limit for number of members that can be in a stage channel. - rtc_region: Optional[:class:`VoiceRegion`] + rtc_region: Optional[:class:`str`] The region for the stage channel's voice communication. A value of ``None`` indicates automatic voice region detection. video_quality_mode: :class:`VideoQualityMode` @@ -1304,7 +1309,7 @@ class StageChannel(VocalGuildChannel): sync_permissions: int = ..., category: Optional[CategoryChannel] = ..., overwrites: Mapping[Union[Role, Member], PermissionOverwrite] = ..., - rtc_region: Optional[VoiceRegion] = ..., + rtc_region: Optional[str] = ..., video_quality_mode: VideoQualityMode = ..., reason: Optional[str] = ..., ) -> Optional[StageChannel]: @@ -1328,6 +1333,9 @@ class StageChannel(VocalGuildChannel): .. versionchanged:: 2.0 Edits are no longer in-place, the newly edited channel is returned instead. + .. versionchanged:: 2.0 + The ``region`` parameter now accepts :class:`str` instead of an enum. + Parameters ---------- name: :class:`str` @@ -1345,7 +1353,7 @@ class StageChannel(VocalGuildChannel): overwrites: :class:`Mapping` A :class:`Mapping` of target (either a role or a member) to :class:`PermissionOverwrite` to apply to the channel. - rtc_region: Optional[:class:`VoiceRegion`] + rtc_region: Optional[:class:`str`] The new region for the stage channel's voice communication. A value of ``None`` indicates automatic voice region detection. video_quality_mode: :class:`VideoQualityMode` diff --git a/discord/client.py b/discord/client.py index e49cc2aeb..9dd71ca19 100644 --- a/discord/client.py +++ b/discord/client.py @@ -58,7 +58,7 @@ from .channel import _threaded_channel_factory, PartialMessageable from .enums import ChannelType from .mentions import AllowedMentions from .errors import * -from .enums import Status, VoiceRegion +from .enums import Status from .flags import ApplicationFlags, Intents from .gateway import * from .activity import ActivityTypes, BaseActivity, create_activity @@ -1345,7 +1345,6 @@ class Client: self, *, name: str, - region: Union[VoiceRegion, str] = VoiceRegion.us_west, icon: bytes = MISSING, code: str = MISSING, ) -> Guild: @@ -1357,15 +1356,13 @@ class Client: .. versionchanged:: 2.0 - ``name`` and ``region``, and ``icon`` parameters are now keyword-only. + ``name`` and ``icon`` parameters are now keyword-only. + The `region`` parameter has been removed. Parameters ---------- name: :class:`str` The name of the guild. - region: :class:`.VoiceRegion` - The region for the voice communication server. - Defaults to :attr:`.VoiceRegion.us_west`. icon: Optional[:class:`bytes`] The :term:`py:bytes-like object` representing the icon. See :meth:`.ClientUser.edit` for more details on what is expected. @@ -1392,12 +1389,10 @@ class Client: else: icon_base64 = None - region_value = str(region) - if code: - data = await self.http.create_from_template(code, name, region_value, icon_base64) + data = await self.http.create_from_template(code, name, icon_base64) else: - data = await self.http.create_guild(name, region_value, icon_base64) + data = await self.http.create_guild(name, icon_base64) return Guild(data=data, state=self._connection) async def fetch_stage_instance(self, channel_id: int, /) -> StageInstance: diff --git a/discord/enums.py b/discord/enums.py index 4488198a8..522321fb0 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -30,7 +30,6 @@ __all__ = ( 'Enum', 'ChannelType', 'MessageType', - 'VoiceRegion', 'SpeakingState', 'VerificationLevel', 'ContentFilter', @@ -220,35 +219,6 @@ class MessageType(Enum): guild_invite_reminder = 22 -class VoiceRegion(Enum): - us_west = 'us-west' - us_east = 'us-east' - us_south = 'us-south' - us_central = 'us-central' - eu_west = 'eu-west' - eu_central = 'eu-central' - singapore = 'singapore' - london = 'london' - sydney = 'sydney' - amsterdam = 'amsterdam' - frankfurt = 'frankfurt' - brazil = 'brazil' - hongkong = 'hongkong' - russia = 'russia' - japan = 'japan' - southafrica = 'southafrica' - south_korea = 'south-korea' - india = 'india' - europe = 'europe' - dubai = 'dubai' - vip_us_east = 'vip-us-east' - vip_us_west = 'vip-us-west' - vip_amsterdam = 'vip-amsterdam' - - def __str__(self): - return self.value - - class SpeakingState(Enum): none = 0 voice = 1 diff --git a/discord/guild.py b/discord/guild.py index 87296bb87..d395e7e53 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -59,7 +59,6 @@ from .channel import _threaded_guild_channel_factory from .enums import ( AuditLogAction, VideoQualityMode, - VoiceRegion, ChannelType, try_enum, VerificationLevel, @@ -171,9 +170,6 @@ class Guild(Hashable): All stickers that the guild owns. .. versionadded:: 2.0 - region: :class:`VoiceRegion` - The region the guild belongs on. There is a chance that the region - will be a :class:`str` if the value is not recognised by the enumerator. afk_timeout: :class:`int` The timeout to get sent to the AFK channel. afk_channel: Optional[:class:`VoiceChannel`] @@ -425,7 +421,6 @@ class Guild(Hashable): self._member_count: int = member_count self.name: str = guild.get('name', '') - self.region: VoiceRegion = try_enum(VoiceRegion, guild.get('region')) self.verification_level: VerificationLevel = try_enum(VerificationLevel, guild.get('verification_level')) self.default_notifications: NotificationLevel = try_enum( NotificationLevel, guild.get('default_message_notifications') @@ -1234,7 +1229,7 @@ class Guild(Hashable): position: int = MISSING, bitrate: int = MISSING, user_limit: int = MISSING, - rtc_region: Optional[VoiceRegion] = MISSING, + rtc_region: Optional[str] = MISSING, video_quality_mode: VideoQualityMode = MISSING, overwrites: Dict[Union[Role, Member], PermissionOverwrite] = MISSING, ) -> VoiceChannel: @@ -1261,7 +1256,7 @@ class Guild(Hashable): The channel's preferred audio bitrate in bits per second. user_limit: :class:`int` The channel's limit for number of members that can be in a voice channel. - rtc_region: Optional[:class:`VoiceRegion`] + rtc_region: Optional[:class:`str`] The region for the voice channel's voice communication. A value of ``None`` indicates automatic voice region detection. @@ -1298,7 +1293,7 @@ class Guild(Hashable): options['user_limit'] = user_limit if rtc_region is not MISSING: - options['rtc_region'] = None if rtc_region is None else str(rtc_region) + options['rtc_region'] = None if rtc_region is None else rtc_region if video_quality_mode is not MISSING: options['video_quality_mode'] = video_quality_mode.value @@ -1468,7 +1463,6 @@ class Guild(Hashable): splash: Optional[bytes] = MISSING, discovery_splash: Optional[bytes] = MISSING, community: bool = MISSING, - region: Optional[Union[str, VoiceRegion]] = MISSING, afk_channel: Optional[VoiceChannel] = MISSING, owner: Snowflake = MISSING, afk_timeout: int = MISSING, @@ -1498,6 +1492,9 @@ class Guild(Hashable): .. versionchanged:: 2.0 The newly updated guild is returned. + .. versionchanged:: 2.0 + The ``region`` keyword parameter has been removed. + Parameters ---------- name: :class:`str` @@ -1526,8 +1523,6 @@ class Guild(Hashable): community: :class:`bool` Whether the guild should be a Community guild. If set to ``True``\, both ``rules_channel`` and ``public_updates_channel`` parameters are required. - region: Union[:class:`str`, :class:`VoiceRegion`] - The new region for the guild's voice communication. afk_channel: Optional[:class:`VoiceChannel`] The new channel that is the AFK channel. Could be ``None`` for no AFK channel. afk_timeout: :class:`int` @@ -1656,9 +1651,6 @@ class Guild(Hashable): fields['owner_id'] = owner.id - if region is not MISSING: - fields['region'] = str(region) - if verification_level is not MISSING: if not isinstance(verification_level, VerificationLevel): raise InvalidArgument('verification_level field must be of type VerificationLevel') diff --git a/discord/template.py b/discord/template.py index 0af24c305..4dd26b186 100644 --- a/discord/template.py +++ b/discord/template.py @@ -26,7 +26,6 @@ from __future__ import annotations from typing import Any, Optional, TYPE_CHECKING from .utils import parse_time, _get_as_snowflake, _bytes_to_base64_data, MISSING -from .enums import VoiceRegion from .guild import Guild # fmt: off @@ -168,20 +167,20 @@ class Template: f' creator={self.creator!r} source_guild={self.source_guild!r} is_dirty={self.is_dirty}>' ) - async def create_guild(self, name: str, region: Optional[VoiceRegion] = None, icon: Any = None) -> Guild: + async def create_guild(self, name: str, icon: bytes = MISSING) -> Guild: """|coro| Creates a :class:`.Guild` using the template. Bot accounts in more than 10 guilds are not allowed to create guilds. + .. versionchanged:: 2.0 + The ``region`` parameter has been removed. + Parameters ---------- name: :class:`str` The name of the guild. - region: :class:`.VoiceRegion` - The region for the voice communication server. - Defaults to :attr:`.VoiceRegion.us_west`. icon: :class:`bytes` The :term:`py:bytes-like object` representing the icon. See :meth:`.ClientUser.edit` for more details on what is expected. @@ -199,13 +198,11 @@ class Template: The guild created. This is not the same guild that is added to cache. """ - if icon is not None: - icon = _bytes_to_base64_data(icon) - - region = region or VoiceRegion.us_west - region_value = region.value + base64_icon = None + if icon is not MISSING: + base64_icon = _bytes_to_base64_data(icon) - data = await self._state.http.create_from_template(self.code, name, region_value, icon) + data = await self._state.http.create_from_template(self.code, name, base64_icon) return Guild(data=data, state=self._state) async def sync(self) -> Template: diff --git a/docs/api.rst b/docs/api.rst index 284d0d311..240a59a7a 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1535,89 +1535,6 @@ of :class:`enum.Enum`. An alias for :attr:`paragraph`. -.. class:: VoiceRegion - - Specifies the region a voice server belongs to. - - .. attribute:: amsterdam - - The Amsterdam region. - .. attribute:: brazil - - The Brazil region. - .. attribute:: dubai - - The Dubai region. - - .. versionadded:: 1.3 - - .. attribute:: eu_central - - The EU Central region. - .. attribute:: eu_west - - The EU West region. - .. attribute:: europe - - The Europe region. - - .. versionadded:: 1.3 - - .. attribute:: frankfurt - - The Frankfurt region. - .. attribute:: hongkong - - The Hong Kong region. - .. attribute:: india - - The India region. - - .. versionadded:: 1.2 - - .. attribute:: japan - - The Japan region. - .. attribute:: london - - The London region. - .. attribute:: russia - - The Russia region. - .. attribute:: singapore - - The Singapore region. - .. attribute:: southafrica - - The South Africa region. - .. attribute:: south_korea - - The South Korea region. - .. attribute:: sydney - - The Sydney region. - .. attribute:: us_central - - The US Central region. - .. attribute:: us_east - - The US East region. - .. attribute:: us_south - - The US South region. - .. attribute:: us_west - - The US West region. - .. attribute:: vip_amsterdam - - The Amsterdam region for VIP guilds. - .. attribute:: vip_us_east - - The US East region for VIP guilds. - .. attribute:: vip_us_west - - The US West region for VIP guilds. - .. class:: VerificationLevel Specifies a :class:`Guild`\'s verification level, which is the criteria in @@ -2937,12 +2854,6 @@ AuditLogDiff :type: Union[:class:`Member`, :class:`User`] - .. attribute:: region - - The guild's voice region. See also :attr:`Guild.region`. - - :type: :class:`VoiceRegion` - .. attribute:: afk_channel The guild's AFK channel. @@ -3261,7 +3172,7 @@ AuditLogDiff See also :attr:`VoiceChannel.rtc_region`. - :type: :class:`VoiceRegion` + :type: :class:`str` .. attribute:: video_quality_mode