Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from Rapptz:master #17

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,10 +1039,6 @@ async def clone(

.. versionadded:: 1.1

.. versionchanged:: 2.5

The ``category`` keyword-only parameter was added.

Parameters
------------
name: Optional[:class:`str`]
Expand All @@ -1051,6 +1047,8 @@ async def clone(
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.

Expand Down
43 changes: 13 additions & 30 deletions discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,14 +532,16 @@ async def clone(
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,
Expand Down Expand Up @@ -1395,7 +1397,9 @@ async def create_webhook(self, *, name: str, avatar: Optional[bytes] = None, rea
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,
Expand All @@ -1409,6 +1413,7 @@ async def clone(self, *, name: Optional[str] = None, reason: Optional[str] = Non
return await self._clone_impl(
base,
name=name,
category=category,
reason=reason,
)

Expand Down Expand Up @@ -1506,18 +1511,6 @@ def type(self) -> Literal[ChannelType.voice]:
""":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:
...
Expand Down Expand Up @@ -1788,16 +1781,6 @@ def type(self) -> Literal[ChannelType.stage_voice]:
""":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.
Expand Down
6 changes: 6 additions & 0 deletions discord/ext/commands/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ async def wave(ctx, to: discord.User = commands.parameter(default=lambda ctx: ct

.. versionadded:: 2.3
"""
if isinstance(default, Parameter):
if displayed_default is empty:
displayed_default = default._displayed_default

default = default._default

return Parameter(
name='empty',
kind=inspect.Parameter.POSITIONAL_OR_KEYWORD,
Expand Down
4 changes: 2 additions & 2 deletions discord/sku.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@

from typing import AsyncIterator, Optional, TYPE_CHECKING

from datetime import datetime

from . import utils
from .enums import try_enum, SKUType, EntitlementType
from .flags import SKUFlags
from .object import Object
from .subscription import Subscription

if TYPE_CHECKING:
from datetime import datetime

from .abc import SnowflakeTime, Snowflake
from .guild import Guild
from .state import ConnectionState
Expand Down
Loading