mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-19 15:36:02 +00:00
Allow editing of channel types for news and text channels
This commit is contained in:
parent
12e31bb933
commit
bd1420b5f0
@ -31,6 +31,7 @@ from collections import namedtuple
|
||||
|
||||
from .iterators import HistoryIterator
|
||||
from .context_managers import Typing
|
||||
from .enums import ChannelType
|
||||
from .errors import InvalidArgument, ClientException, HTTPException
|
||||
from .permissions import PermissionOverwrite, Permissions
|
||||
from .role import Role
|
||||
@ -280,6 +281,15 @@ class GuildChannel:
|
||||
perms.append(payload)
|
||||
options['permission_overwrites'] = perms
|
||||
|
||||
try:
|
||||
ch_type = options['type']
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
if not isinstance(ch_type, ChannelType):
|
||||
raise InvalidArgument('type field must be of type ChannelType')
|
||||
options['type'] = ch_type.value
|
||||
|
||||
if options:
|
||||
data = await self._state.http.edit_channel(self.id, reason=reason, **options)
|
||||
self._update(self.guild, data)
|
||||
|
@ -197,6 +197,9 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
||||
.. versionchanged:: 1.3
|
||||
The ``overwrites`` keyword-only parameter was added.
|
||||
|
||||
.. versionchanged:: 1.4
|
||||
The ``type`` keyword-only parameter was added.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
name: :class:`str`
|
||||
@ -216,6 +219,10 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
||||
slowmode_delay: :class:`int`
|
||||
Specifies the slowmode rate limit for user in this channel, in seconds.
|
||||
A value of `0` disables slowmode. The maximum value possible is `21600`.
|
||||
type: :class:`ChannelType`
|
||||
Change the type of this text channel. Currently, only conversion between
|
||||
:attr:`ChannelType.text` and :attr:`ChannelType.news` is supported. This
|
||||
is only available to guilds that contain ``NEWS`` in :attr:`Guild.features`.
|
||||
reason: Optional[:class:`str`]
|
||||
The reason for editing this channel. Shows up on the audit log.
|
||||
overwrites: :class:`dict`
|
||||
|
@ -529,7 +529,8 @@ class HTTPClient:
|
||||
def edit_channel(self, channel_id, *, reason=None, **options):
|
||||
r = Route('PATCH', '/channels/{channel_id}', channel_id=channel_id)
|
||||
valid_keys = ('name', 'parent_id', 'topic', 'bitrate', 'nsfw',
|
||||
'user_limit', 'position', 'permission_overwrites', 'rate_limit_per_user')
|
||||
'user_limit', 'position', 'permission_overwrites', 'rate_limit_per_user',
|
||||
'type')
|
||||
payload = {
|
||||
k: v for k, v in options.items() if k in valid_keys
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user