diff --git a/discord/abc.py b/discord/abc.py index 365fcebfc..0ca114526 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -231,6 +231,11 @@ class GuildChannel: else: parent_id = parent and parent.id + try: + options['rate_limit_per_user'] = options.pop('slowmode_delay') + except KeyError: + pass + lock_permissions = options.pop('sync_permissions', False) try: diff --git a/discord/channel.py b/discord/channel.py index eb157ad91..32faf983d 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -78,10 +78,15 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): position: :class:`int` The position in the channel list. This is a number that starts at 0. e.g. the top channel is position 0. + slowmode_delay: :class:`int` + The number of seconds a member must wait between sending messages + in this channel. A value of `0` denotes that it is disabled. + Bots and users with :attr:`~Permissions.manage_channels` or + :attr:`~Permissions.manage_messages` bypass slowmode. """ __slots__ = ('name', 'id', 'guild', 'topic', '_state', 'nsfw', - 'category_id', 'position', '_overwrites') + 'category_id', 'position', 'slowmode_delay', '_overwrites') def __init__(self, *, state, guild, data): self._state = state @@ -98,6 +103,8 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): self.topic = data.get('topic') self.position = data['position'] self.nsfw = data.get('nsfw', False) + # Does this need coercion into `int`? No idea yet. + self.slowmode_delay = data.get('rate_limit_per_user', 0) self._fill_overwrites(data) async def _get_channel(self): @@ -133,21 +140,24 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): Parameters ---------- - name: str + name: :class:`str` The new channel name. - topic: str + topic: :class:`str` The new channel's topic. - position: int + position: :class:`int` The new channel's position. - nsfw: bool + nsfw: :class:`bool` To mark the channel as NSFW or not. - sync_permissions: bool + sync_permissions: :class:`bool` Whether to sync permissions with the channel's new or pre-existing category. Defaults to ``False``. category: Optional[:class:`CategoryChannel`] The new category for this channel. Can be ``None`` to remove the category. - reason: Optional[str] + slowmode_delay: :class:`int` + Specifies the slowmode rate limit for user in this channel. A value of + `0` disables slowmode. The maximum value possible is `120`. + reason: Optional[:class:`str`] The reason for editing this channel. Shows up on the audit log. Raises diff --git a/discord/http.py b/discord/http.py index 2d5c67fb8..6c2b548c6 100644 --- a/discord/http.py +++ b/discord/http.py @@ -495,7 +495,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') + valid_keys = ('name', 'parent_id', 'topic', 'bitrate', 'nsfw', + 'user_limit', 'position', 'permission_overwrites', 'rate_limit_per_user') payload = { k: v for k, v in options.items() if k in valid_keys }