Browse Source

Undo overwrites changes, add missing permission 1 << 9, fix presence mess

Co-authored-by: ThatGuyJustin <[email protected]>
pull/152/head
“elderlabs” 6 years ago
parent
commit
6197fe78ea
  1. 10
      disco/types/channel.py
  2. 1
      disco/types/guild.py
  3. 3
      disco/types/permissions.py

10
disco/types/channel.py

@ -123,7 +123,7 @@ class Channel(SlottedModel, Permissible):
type = Field(enum(ChannelType))
guild_id = Field(snowflake)
position = Field(int)
permission_overwrites = AutoDictField(PermissionOverwrite, 'id', alias='permission_overwrites')
overwrites = AutoDictField(PermissionOverwrite, 'id', alias='permission_overwrites')
name = Field(text)
topic = Field(text)
nsfw = Field(bool)
@ -144,7 +144,7 @@ class Channel(SlottedModel, Permissible):
def after_load(self):
# TODO: hackfix
self.attach(six.itervalues(self.permission_overwrites), {'channel_id': self.id, 'channel': self})
self.attach(six.itervalues(self.overwrites), {'channel_id': self.id, 'channel': self})
def __str__(self):
return u'#{}'.format(self.name) if self.name else six.text_type(self.id)
@ -168,18 +168,18 @@ class Channel(SlottedModel, Permissible):
base = self.guild.get_permissions(member)
# First grab and apply the everyone overwrite
everyone = self.permission_overwrites.get(self.guild_id)
everyone = self.overwrites.get(self.guild_id)
if everyone:
base -= everyone.deny
base += everyone.allow
for role_id in member.roles:
overwrite = self.permission_overwrites.get(role_id)
overwrite = self.overwrites.get(role_id)
if overwrite:
base -= overwrite.deny
base += overwrite.allow
ow_member = self.permission_overwrites.get(member.user.id)
ow_member = self.overwrites.get(member.user.id)
if ow_member:
base -= ow_member.deny
base += ow_member.allow

1
disco/types/guild.py

@ -387,7 +387,6 @@ class Guild(SlottedModel, Permissible):
voice_states = AutoDictField(VoiceState, 'session_id')
members = AutoDictField(GuildMember, 'id')
channels = AutoDictField(Channel, 'id')
presences = Field(enum(Presence))
max_presences = Field(int, default=5000)
max_members = Field(int)
vanity_url_code = Field(text)

3
disco/types/permissions.py

@ -11,7 +11,8 @@ class Permissions(object):
ADD_REACTIONS = 1 << 6
VIEW_AUDIT_LOG = 1 << 7
PRIORITY_SPEAKER = 1 << 8
READ_MESSAGES = 1 << 10
STREAM = 1 << 9
VIEW_CHANNEL = 1 << 10
SEND_MESSAGES = 1 << 11
SEND_TSS_MESSAGES = 1 << 12
MANAGE_MESSAGES = 1 << 13

Loading…
Cancel
Save