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

feat: Add clone_channel method to guild #794

Merged
merged 8 commits into from May 23, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions interactions/api/models/guild.py
Expand Up @@ -768,6 +768,27 @@ async def create_channel(

return Channel(**res, _client=self._client)

async def clone_channel(self, channel_id: int) -> Channel:
"""
Clones a channel of the guild.

:param channel_id: The id of the channel to clone
:type channel_id: int
:return: The created (cloned) channel
Toricane marked this conversation as resolved.
Show resolved Hide resolved
:rtype: Channel
"""
if not self._client:
raise AttributeError("HTTPClient not found!")
res = await self._client.get_channel(channel_id=channel_id)

res["permission_overwrites"] = [Overwrite(**_) for _ in res["permission_overwrites"]]
[
res.pop(attr, None)
for attr in {"flags", "last_pin_timestamp", "guild_id", "id", "last_message_id"}
]
Nanrech marked this conversation as resolved.
Show resolved Hide resolved

return await self.create_channel(**res)

async def modify_channel(
self,
channel_id: int,
Expand Down
4 changes: 4 additions & 0 deletions interactions/api/models/guild.pyi
Expand Up @@ -224,6 +224,10 @@ class Guild(DictSerializerMixin):
nsfw: Optional[bool] = MISSING,
reason: Optional[str] = None,
) -> Channel: ...
async def clone_channel(
self,
channel_id: int
) -> Channel: ...
async def modify_channel(
self,
channel_id: int,
Expand Down