Skip to content

Commit f21a0c2

Browse files
committed
Transform InviteFlags for audit log
1 parent a4fe2cb commit f21a0c2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

discord/audit_logs.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ def _transform_applied_forum_tags(entry: AuditLogEntry, data: List[Snowflake]) -
145145
return [Object(id=tag_id, type=ForumTag) for tag_id in data]
146146

147147

148-
def _transform_overloaded_flags(entry: AuditLogEntry, data: int) -> Union[int, flags.ChannelFlags]:
149-
# The `flags` key is definitely overloaded. Right now it's for channels and threads but
148+
def _transform_overloaded_flags(entry: AuditLogEntry, data: int) -> Union[int, flags.ChannelFlags, flags.InviteFlags]:
149+
# The `flags` key is definitely overloaded. Right now it's for channels, threads and invites but
150150
# I am aware of `member.flags` and `user.flags` existing. However, this does not impact audit logs
151151
# at the moment but better safe than sorry.
152152
channel_audit_log_types = (
@@ -157,9 +157,16 @@ def _transform_overloaded_flags(entry: AuditLogEntry, data: int) -> Union[int, f
157157
enums.AuditLogAction.thread_update,
158158
enums.AuditLogAction.thread_delete,
159159
)
160+
invite_audit_log_types = (
161+
enums.AuditLogAction.invite_create,
162+
enums.AuditLogAction.invite_update,
163+
enums.AuditLogAction.invite_delete,
164+
)
160165

161166
if entry.action in channel_audit_log_types:
162167
return flags.ChannelFlags._from_value(data)
168+
elif entry.action in invite_audit_log_types:
169+
return flags.InviteFlags._from_value(data)
163170
return data
164171

165172

0 commit comments

Comments
 (0)