Fix AuditLogDiff.type for webhooks

This commit is contained in:
o-wo 2023-02-22 04:01:01 +05:30 committed by GitHub
parent 2cde1133f9
commit b19897fce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -283,11 +283,15 @@ def _flag_transformer(cls: Type[F]) -> Callable[[AuditLogEntry, Union[int, str]]
return _transform return _transform
def _transform_type(entry: AuditLogEntry, data: Union[int, str]) -> Union[enums.ChannelType, enums.StickerType, str]: def _transform_type(
entry: AuditLogEntry, data: Union[int, str]
) -> Union[enums.ChannelType, enums.StickerType, enums.WebhookType, str]:
if entry.action.name.startswith('sticker_'): if entry.action.name.startswith('sticker_'):
return enums.try_enum(enums.StickerType, data) return enums.try_enum(enums.StickerType, data)
elif entry.action.name.startswith('integration_'): elif entry.action.name.startswith('integration_'):
return data # type: ignore # integration type is str return data # type: ignore # integration type is str
elif entry.action.name.startswith('webhook_'):
return enums.try_enum(enums.WebhookType, data)
else: else:
return enums.try_enum(enums.ChannelType, data) return enums.try_enum(enums.ChannelType, data)

View File

@ -3517,9 +3517,9 @@ AuditLogDiff
.. attribute:: type .. attribute:: type
The type of channel, sticker or integration. The type of channel, sticker, webhook or integration.
:type: Union[:class:`ChannelType`, :class:`StickerType`, :class:`str`] :type: Union[:class:`ChannelType`, :class:`StickerType`, :class:`WebhookType`, :class:`str`]
.. attribute:: topic .. attribute:: topic