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 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
19 changes: 19 additions & 0 deletions interactions/api/models/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,25 @@ 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 cloned channel
: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"]]
for attr in {"flags", "guild_id", "id", "last_message_id", "last_pin_timestamp"}:
res.pop(attr, None)

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
Original file line number Diff line number Diff line change
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