Allow editing of overwrites in Channel.edit()

This commit is contained in:
CapnS authored and Rapptz committed 2019-12-04 18:40:38 -05:00
1 parent c62b6c3e88
commit 072cef3bb6
2 files changed
+43 -2

No files matched your search

+22
View File
@@ -260,6 +260,28 @@ class GuildChannel:
else: else:
await self._move(position, parent_id=parent_id, lock_permissions=lock_permissions, reason=reason) await self._move(position, parent_id=parent_id, lock_permissions=lock_permissions, reason=reason)
overwrites = options.get('overwrites', None)
if overwrites:
perms = []
for target, perm in overwrites.items():
if not isinstance(perm, PermissionOverwrite):
raise InvalidArgument('Expected PermissionOverwrite received {0.__name__}'.format(type(perm)))
allow, deny = perm.pair()
payload = {
'allow': allow.value,
'deny': deny.value,
'id': target.id
}
if isinstance(target, Role):
payload['type'] = 'role'
else:
payload['type'] = 'member'
perms.append(payload)
options['permission_overwrites'] = perms
if options: if options:
data = await self._state.http.edit_channel(self.id, reason=reason, **options) data = await self._state.http.edit_channel(self.id, reason=reason, **options)
self._update(self.guild, data) self._update(self.guild, data)
+21 -2
View File
@@ -215,11 +215,17 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
A value of `0` disables slowmode. The maximum value possible is `21600`. A value of `0` disables slowmode. The maximum value possible is `21600`.
reason: Optional[:class:`str`] reason: Optional[:class:`str`]
The reason for editing this channel. Shows up on the audit log. The reason for editing this channel. Shows up on the audit log.
overwrites: :class:`dict`
A :class:`dict` of target (either a role or a member) to
:class:`PermissionOverwrite` to apply to the channel.
.. versionadded:: 1.3.0
Raises Raises
------ ------
InvalidArgument InvalidArgument
If position is less than 0 or greater than the number of channels. If position is less than 0 or greater than the number of channels, or if
the permission overwrite information is not in proper form.
Forbidden Forbidden
You do not have permissions to edit the channel. You do not have permissions to edit the channel.
HTTPException HTTPException
@@ -654,9 +660,16 @@ class VoiceChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable):
category. category.
reason: Optional[:class:`str`] reason: Optional[:class:`str`]
The reason for editing this channel. Shows up on the audit log. The reason for editing this channel. Shows up on the audit log.
overwrites: :class:`dict`
A :class:`dict` of target (either a role or a member) to
:class:`PermissionOverwrite` to apply to the channel.
.. versionadded:: 1.3.0
Raises Raises
------ ------
InvalidArgument
If the permission overwrite information is not in proper form.
Forbidden Forbidden
You do not have permissions to edit the channel. You do not have permissions to edit the channel.
HTTPException HTTPException
@@ -933,11 +946,17 @@ class StoreChannel(discord.abc.GuildChannel, Hashable):
category. category.
reason: Optional[:class:`str`] reason: Optional[:class:`str`]
The reason for editing this channel. Shows up on the audit log. The reason for editing this channel. Shows up on the audit log.
overwrites: :class:`dict`
A :class:`dict` of target (either a role or a member) to
:class:`PermissionOverwrite` to apply to the channel.
.. versionadded:: 1.3
Raises Raises
------ ------
InvalidArgument InvalidArgument
If position is less than 0 or greater than the number of channels. If position is less than 0 or greater than the number of channels, or if
the permission overwrite information is not in proper form.
Forbidden Forbidden
You do not have permissions to edit the channel. You do not have permissions to edit the channel.
HTTPException HTTPException