aboutsummaryrefslogtreecommitdiff
path: root/discord/permissions.py
diff options
context:
space:
mode:
authorDevilXD <[email protected]>2019-01-28 22:47:26 +0100
committerRapptz <[email protected]>2019-01-28 22:22:54 -0500
commit9d92939fbe07b52889862f216687e6c91931ac4f (patch)
tree6f1ab2df6121772e5c1f44d36ddf4f318a7a52e7 /discord/permissions.py
parentWarn on high latency and blocking heartbeat (diff)
downloaddiscord.py-9d92939fbe07b52889862f216687e6c91931ac4f.tar.xz
discord.py-9d92939fbe07b52889862f216687e6c91931ac4f.zip
Added support for comparing PermissionOverwrites
When trying to check if a specific permission overwrite is already set on a channel, it can be done by fetching the already existing overwrite and comparing it with a one you want to set. Comparing them directly wasn't possible before, and this small change allows for that. Could be expanded for other comparison operators, not sure how it would work though.
Diffstat (limited to 'discord/permissions.py')
-rw-r--r--discord/permissions.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/discord/permissions.py b/discord/permissions.py
index 4c2d5f70..a72a6290 100644
--- a/discord/permissions.py
+++ b/discord/permissions.py
@@ -526,6 +526,10 @@ class PermissionOverwrite:
+-----------+------------------------------------------+
| Operation | Description |
+===========+==========================================+
+ | x == y | Checks if two overwrites are equal. |
+ +-----------+------------------------------------------+
+ | x != y | Checks if two overwrites are not equal. |
+ +-----------+------------------------------------------+
| iter(x) | Returns an iterator of (perm, value) |
| | pairs. This allows this class to be used |
| | as an iterable in e.g. set/list/dict |
@@ -549,6 +553,9 @@ class PermissionOverwrite:
setattr(self, key, value)
+ def __eq__(self, other):
+ return self._values == other._values
+
def _set(self, key, value):
if value not in (True, None, False):
raise TypeError('Expected bool or NoneType, received {0.__class__.__name__}'.format(value))