Browse Source

Formatting

pull/10109/head
dolfies 3 years ago
parent
commit
d49cb077e7
  1. 17
      discord/audit_logs.py
  2. 10
      discord/guild.py

17
discord/audit_logs.py

@ -219,7 +219,7 @@ class AuditLogChanges:
for elem in data:
attr = elem['key']
# special cases for role add/remove
# Special cases for role add/remove
if attr == '$add':
self._handle_role(self.before, self.after, entry, elem['new_value']) # type: ignore
continue
@ -257,7 +257,7 @@ class AuditLogChanges:
setattr(self.after, attr, after)
# add an alias
# Add an alias
if hasattr(self.after, 'colour'):
self.after.color = self.after.colour
self.before.color = self.before.colour
@ -364,13 +364,12 @@ class AuditLogEntry(Hashable):
self.action = enums.try_enum(enums.AuditLogAction, data['action_type'])
self.id = int(data['id'])
# this key is technically not usually present
self.reason = data.get('reason')
self.extra = data.get('options')
if isinstance(self.action, enums.AuditLogAction) and self.extra:
if self.action is enums.AuditLogAction.member_prune:
# member prune has two keys with useful information
# Member prune has two keys with useful information
self.extra: _AuditLogProxyMemberPrune = type(
'_AuditLogProxy', (), {k: int(v) for k, v in self.extra.items()}
)()
@ -388,7 +387,7 @@ class AuditLogEntry(Hashable):
}
self.extra: _AuditLogProxyMemberDisconnect = type('_AuditLogProxy', (), elems)()
elif self.action.name.endswith('pin'):
# the pin actions have a dict with some information
# The pin actions have a dict with some information
channel_id = int(self.extra['channel_id'])
elems = {
'channel': self.guild.get_channel(channel_id) or Object(id=channel_id),
@ -396,7 +395,7 @@ class AuditLogEntry(Hashable):
}
self.extra: _AuditLogProxyPinAction = type('_AuditLogProxy', (), elems)()
elif self.action.name.startswith('overwrite_'):
# the overwrite_ actions have a dict with some information
# The overwrite_ actions have a dict with some information
instance_id = int(self.extra['id'])
the_type = self.extra.get('type')
if the_type == '1':
@ -424,7 +423,7 @@ class AuditLogEntry(Hashable):
]
# fmt: on
# this key is not present when the above is present, typically.
# This key is not present when the above is present, typically
# It's a list of { new_value: a, old_value: b, key: c }
# where new_value and old_value are not guaranteed to be there depending
# on the action type, so let's just fetch it for now and only turn it
@ -489,8 +488,8 @@ class AuditLogEntry(Hashable):
return self.guild.get_role(target_id) or Object(id=target_id)
def _convert_target_invite(self, target_id: int) -> Invite:
# invites have target_id set to null
# so figure out which change has the full invite data
# Invites have target_id set to null
# So figure out which change has the full invite data
changeset = self.before if self.action is enums.AuditLogAction.invite_delete else self.after
fake_payload = {

10
discord/guild.py

@ -969,7 +969,7 @@ class Guild(Hashable):
if overwrites is MISSING:
overwrites = {}
elif not isinstance(overwrites, dict):
raise InvalidArgument('overwrites parameter expects a dict.')
raise InvalidArgument('overwrites parameter expects a dict')
perms = []
for target, perm in overwrites.items():
@ -1533,7 +1533,7 @@ class Guild(Hashable):
if owner is not MISSING:
if self.owner_id != self._state.self_id:
raise InvalidArgument('To transfer ownership you must be the owner of the guild.')
raise InvalidArgument('To transfer ownership you must be the owner of the guild')
fields['owner_id'] = owner.id
@ -1824,7 +1824,7 @@ class Guild(Hashable):
then this returns ``None``.
"""
if not isinstance(days, int):
raise InvalidArgument(f'Expected int for ``days``, received {days.__class__.__name__} instead.')
raise InvalidArgument(f'Expected int for ``days``, received {days.__class__.__name__} instead')
if roles:
role_ids = [str(role.id) for role in roles]
@ -1914,7 +1914,7 @@ class Guild(Hashable):
The number of members estimated to be pruned.
"""
if not isinstance(days, int):
raise InvalidArgument(f'Expected int for ``days``, received {days.__class__.__name__} instead.')
raise InvalidArgument(f'Expected int for ``days``, received {days.__class__.__name__} instead')
if roles:
role_ids = [str(role.id) for role in roles]
@ -2491,7 +2491,7 @@ class Guild(Hashable):
A list of all the roles in the guild.
"""
if not isinstance(positions, dict):
raise InvalidArgument('positions parameter expects a dict.')
raise InvalidArgument('positions parameter expects a dict')
role_positions: List[Dict[str, Any]] = []
for role, position in positions.items():

Loading…
Cancel
Save