mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-08 10:53:10 +00:00
Add abc.GuildChannel.clone to clone a channel with another name.
Fixes #2093
This commit is contained in:
@ -603,6 +603,46 @@ class GuildChannel:
|
||||
else:
|
||||
raise InvalidArgument('Invalid overwrite type provided.')
|
||||
|
||||
async def _clone_impl(self, base_attrs, *, name=None, reason=None):
|
||||
base_attrs['permission_overwrites'] = [
|
||||
x._asdict() for x in self._overwrites
|
||||
]
|
||||
base_attrs['parent_id'] = self.category_id
|
||||
base_attrs['name'] = name or self.name
|
||||
guild_id = self.guild.id
|
||||
cls = self.__class__
|
||||
data = await self._state.http.create_channel(guild_id, self._type, reason=reason, **base_attrs)
|
||||
obj = cls(state=self._state, guild=self.guild, data=data)
|
||||
|
||||
# temporarily add it to the cache
|
||||
self.guild._channels[obj.id] = obj
|
||||
return obj
|
||||
|
||||
async def clone(self, *, name=None, reason=None):
|
||||
"""|coro|
|
||||
|
||||
Clones this channel. This creates a channel with the same properties
|
||||
as this channel.
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
|
||||
Parameters
|
||||
------------
|
||||
name: Optional[:class:`str`]
|
||||
The name of the new channel. If not provided, defaults to this
|
||||
channel name.
|
||||
reason: Optional[:class:`str`]
|
||||
The reason for cloning this channel. Shows up on the audit log.
|
||||
|
||||
Raises
|
||||
-------
|
||||
Forbidden
|
||||
You do not have the proper permissions to create this channel.
|
||||
HTTPException
|
||||
Creating the channel failed.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
async def create_invite(self, *, reason=None, **fields):
|
||||
"""|coro|
|
||||
|
||||
|
Reference in New Issue
Block a user