Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Fixes to permission calculations #123

Merged
merged 2 commits into from
Mar 9, 2019
Merged

Fixes to permission calculations #123

merged 2 commits into from
Mar 9, 2019

Conversation

jlu5
Copy link
Contributor

@jlu5 jlu5 commented Feb 12, 2019

This patch seems to fix some permissions calculation issues, from #98 (comment)

  • When I have a permission that is TRUE for the guild and NEUTRAL for the channel, channel.get_permissions() returns False for any UID and permission (even when I'm the server owner!).
  • When I have a permission that is TRUE for the guild and FALSE for the channel, disco hits a TypeError when calculating permissions:
2019-02-11 22:57:18,555 [INFO] (discord) bursting guild 497939890063802369/OVD-NET
Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 716, in gevent._greenlet.Greenlet.run
  File "/home/pylink/.local/lib/python3.5/site-packages/holster/emitter.py", line 72, in __call__
    return self.callback(*args, **kwargs)
  File "/home/pylink/.local/lib/python3.5/site-packages/disco_py-0.0.13rc2-py3.5.egg/disco/bot/plugin.py", line 335, in dispatch
    result = func(event, *args, **kwargs)
  File "/home/pylink/pylink-discord/protocols/discord.py", line 169, in on_server_connect
    self._burst_guild(event.guild)
  File "/home/pylink/pylink-discord/protocols/discord.py", line 73, in _burst_guild
    self._burst_new_client(guild, member, pylink_netobj)
  File "/home/pylink/pylink-discord/protocols/discord.py", line 130, in _burst_new_client
    channel_permissions = channel.get_permissions(member)
  File "/home/pylink/.local/lib/python3.5/site-packages/disco_py-0.0.13rc2-py3.5.egg/disco/types/channel.py", line 176, in get_permissions
    denies |= overwrite.deny
TypeError: unsupported operand type(s) for |=: 'int' and 'PermissionValue'
2019-02-12T06:57:18Z <Greenlet "Greenlet-0" at 0x7f8e55a55e48: <holster.emitter.EmitterSubscription object at 0x7f8e55a34240>(<disco.gateway.events.GuildCreate object at 0x7f8e)> failed with TypeError

jlu5 added a commit to PyLink/pylink-discord that referenced this pull request Feb 12, 2019
@b1naryth1ef
Copy link
Owner

Looks fine, permissions are easily the most complicated aspect of Discord (and honestly I don't think anyone gets it 100% right) so I'd love to get a good testing framework around this in the future. That said, thanks for getting this fix in!

@b1naryth1ef b1naryth1ef merged commit 7fbca82 into b1naryth1ef:master Mar 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants