Browse Source

Fix abc.GuildChannel.clone implementations

pull/9978/head
Soheab 6 months ago
committed by GitHub
parent
commit
354ae4208c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      discord/abc.py
  2. 43
      discord/channel.py

6
discord/abc.py

@ -1039,10 +1039,6 @@ class GuildChannel:
.. versionadded:: 1.1
.. versionchanged:: 2.5
The ``category`` keyword-only parameter was added.
Parameters
------------
name: Optional[:class:`str`]
@ -1051,6 +1047,8 @@ class GuildChannel:
category: Optional[:class:`~discord.CategoryChannel`]
The category the new channel belongs to.
This parameter is ignored if cloning a category channel.
.. versionadded:: 2.5
reason: Optional[:class:`str`]
The reason for cloning this channel. Shows up on the audit log.

43
discord/channel.py

@ -532,14 +532,16 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
category: Optional[CategoryChannel] = None,
reason: Optional[str] = None,
) -> TextChannel:
base: Dict[Any, Any] = {
'topic': self.topic,
'nsfw': self.nsfw,
'default_auto_archive_duration': self.default_auto_archive_duration,
'default_thread_rate_limit_per_user': self.default_thread_slowmode_delay,
}
if not self.is_news():
base['rate_limit_per_user'] = self.slowmode_delay
return await self._clone_impl(
{
'topic': self.topic,
'rate_limit_per_user': self.slowmode_delay,
'nsfw': self.nsfw,
'default_auto_archive_duration': self.default_auto_archive_duration,
'default_thread_rate_limit_per_user': self.default_thread_slowmode_delay,
},
base,
name=name,
category=category,
reason=reason,
@ -1395,7 +1397,9 @@ class VocalGuildChannel(discord.abc.Messageable, discord.abc.Connectable, discor
return Webhook.from_state(data, state=self._state)
@utils.copy_doc(discord.abc.GuildChannel.clone)
async def clone(self, *, name: Optional[str] = None, reason: Optional[str] = None) -> Self:
async def clone(
self, *, name: Optional[str] = None, category: Optional[CategoryChannel] = None, reason: Optional[str] = None
) -> Self:
base = {
'bitrate': self.bitrate,
'user_limit': self.user_limit,
@ -1409,6 +1413,7 @@ class VocalGuildChannel(discord.abc.Messageable, discord.abc.Connectable, discor
return await self._clone_impl(
base,
name=name,
category=category,
reason=reason,
)
@ -1506,18 +1511,6 @@ class VoiceChannel(VocalGuildChannel):
""":class:`ChannelType`: The channel's Discord type."""
return ChannelType.voice
@utils.copy_doc(discord.abc.GuildChannel.clone)
async def clone(
self,
*,
name: Optional[str] = None,
category: Optional[CategoryChannel] = None,
reason: Optional[str] = None,
) -> VoiceChannel:
return await self._clone_impl(
{'bitrate': self.bitrate, 'user_limit': self.user_limit}, name=name, category=category, reason=reason
)
@overload
async def edit(self) -> None:
...
@ -1788,16 +1781,6 @@ class StageChannel(VocalGuildChannel):
""":class:`ChannelType`: The channel's Discord type."""
return ChannelType.stage_voice
@utils.copy_doc(discord.abc.GuildChannel.clone)
async def clone(
self,
*,
name: Optional[str] = None,
category: Optional[CategoryChannel] = None,
reason: Optional[str] = None,
) -> StageChannel:
return await self._clone_impl({}, name=name, category=category, reason=reason)
@property
def instance(self) -> Optional[StageInstance]:
"""Optional[:class:`StageInstance`]: The running stage instance of the stage channel.

Loading…
Cancel
Save