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 .. versionadded:: 1.1
.. versionchanged:: 2.5
The ``category`` keyword-only parameter was added.
Parameters Parameters
------------ ------------
name: Optional[:class:`str`] name: Optional[:class:`str`]
@ -1051,6 +1047,8 @@ class GuildChannel:
category: Optional[:class:`~discord.CategoryChannel`] category: Optional[:class:`~discord.CategoryChannel`]
The category the new channel belongs to. The category the new channel belongs to.
This parameter is ignored if cloning a category channel. This parameter is ignored if cloning a category channel.
.. versionadded:: 2.5
reason: Optional[:class:`str`] reason: Optional[:class:`str`]
The reason for cloning this channel. Shows up on the audit log. 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, category: Optional[CategoryChannel] = None,
reason: Optional[str] = None, reason: Optional[str] = None,
) -> TextChannel: ) -> 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( return await self._clone_impl(
{ base,
'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,
},
name=name, name=name,
category=category, category=category,
reason=reason, reason=reason,
@ -1395,7 +1397,9 @@ class VocalGuildChannel(discord.abc.Messageable, discord.abc.Connectable, discor
return Webhook.from_state(data, state=self._state) return Webhook.from_state(data, state=self._state)
@utils.copy_doc(discord.abc.GuildChannel.clone) @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 = { base = {
'bitrate': self.bitrate, 'bitrate': self.bitrate,
'user_limit': self.user_limit, 'user_limit': self.user_limit,
@ -1409,6 +1413,7 @@ class VocalGuildChannel(discord.abc.Messageable, discord.abc.Connectable, discor
return await self._clone_impl( return await self._clone_impl(
base, base,
name=name, name=name,
category=category,
reason=reason, reason=reason,
) )
@ -1506,18 +1511,6 @@ class VoiceChannel(VocalGuildChannel):
""":class:`ChannelType`: The channel's Discord type.""" """:class:`ChannelType`: The channel's Discord type."""
return ChannelType.voice 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 @overload
async def edit(self) -> None: async def edit(self) -> None:
... ...
@ -1788,16 +1781,6 @@ class StageChannel(VocalGuildChannel):
""":class:`ChannelType`: The channel's Discord type.""" """:class:`ChannelType`: The channel's Discord type."""
return ChannelType.stage_voice 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 @property
def instance(self) -> Optional[StageInstance]: def instance(self) -> Optional[StageInstance]:
"""Optional[:class:`StageInstance`]: The running stage instance of the stage channel. """Optional[:class:`StageInstance`]: The running stage instance of the stage channel.

Loading…
Cancel
Save