Browse Source

Add two new audit log event types

pull/9476/merge
Rapptz 2 years ago
parent
commit
00ea67d315
  1. 222
      discord/enums.py
  2. 2
      discord/types/audit_log.py
  3. 12
      docs/api.rst

222
discord/enums.py

@ -314,120 +314,124 @@ class AuditLogActionCategory(Enum):
class AuditLogAction(Enum): class AuditLogAction(Enum):
# fmt: off # fmt: off
guild_update = 1 guild_update = 1
channel_create = 10 channel_create = 10
channel_update = 11 channel_update = 11
channel_delete = 12 channel_delete = 12
overwrite_create = 13 overwrite_create = 13
overwrite_update = 14 overwrite_update = 14
overwrite_delete = 15 overwrite_delete = 15
kick = 20 kick = 20
member_prune = 21 member_prune = 21
ban = 22 ban = 22
unban = 23 unban = 23
member_update = 24 member_update = 24
member_role_update = 25 member_role_update = 25
member_move = 26 member_move = 26
member_disconnect = 27 member_disconnect = 27
bot_add = 28 bot_add = 28
role_create = 30 role_create = 30
role_update = 31 role_update = 31
role_delete = 32 role_delete = 32
invite_create = 40 invite_create = 40
invite_update = 41 invite_update = 41
invite_delete = 42 invite_delete = 42
webhook_create = 50 webhook_create = 50
webhook_update = 51 webhook_update = 51
webhook_delete = 52 webhook_delete = 52
emoji_create = 60 emoji_create = 60
emoji_update = 61 emoji_update = 61
emoji_delete = 62 emoji_delete = 62
message_delete = 72 message_delete = 72
message_bulk_delete = 73 message_bulk_delete = 73
message_pin = 74 message_pin = 74
message_unpin = 75 message_unpin = 75
integration_create = 80 integration_create = 80
integration_update = 81 integration_update = 81
integration_delete = 82 integration_delete = 82
stage_instance_create = 83 stage_instance_create = 83
stage_instance_update = 84 stage_instance_update = 84
stage_instance_delete = 85 stage_instance_delete = 85
sticker_create = 90 sticker_create = 90
sticker_update = 91 sticker_update = 91
sticker_delete = 92 sticker_delete = 92
scheduled_event_create = 100 scheduled_event_create = 100
scheduled_event_update = 101 scheduled_event_update = 101
scheduled_event_delete = 102 scheduled_event_delete = 102
thread_create = 110 thread_create = 110
thread_update = 111 thread_update = 111
thread_delete = 112 thread_delete = 112
app_command_permission_update = 121 app_command_permission_update = 121
automod_rule_create = 140 automod_rule_create = 140
automod_rule_update = 141 automod_rule_update = 141
automod_rule_delete = 142 automod_rule_delete = 142
automod_block_message = 143 automod_block_message = 143
automod_flag_message = 144 automod_flag_message = 144
automod_timeout_member = 145 automod_timeout_member = 145
creator_monetization_request_created = 150
creator_monetization_terms_accepted = 151
# fmt: on # fmt: on
@property @property
def category(self) -> Optional[AuditLogActionCategory]: def category(self) -> Optional[AuditLogActionCategory]:
# fmt: off # fmt: off
lookup: Dict[AuditLogAction, Optional[AuditLogActionCategory]] = { lookup: Dict[AuditLogAction, Optional[AuditLogActionCategory]] = {
AuditLogAction.guild_update: AuditLogActionCategory.update, AuditLogAction.guild_update: AuditLogActionCategory.update,
AuditLogAction.channel_create: AuditLogActionCategory.create, AuditLogAction.channel_create: AuditLogActionCategory.create,
AuditLogAction.channel_update: AuditLogActionCategory.update, AuditLogAction.channel_update: AuditLogActionCategory.update,
AuditLogAction.channel_delete: AuditLogActionCategory.delete, AuditLogAction.channel_delete: AuditLogActionCategory.delete,
AuditLogAction.overwrite_create: AuditLogActionCategory.create, AuditLogAction.overwrite_create: AuditLogActionCategory.create,
AuditLogAction.overwrite_update: AuditLogActionCategory.update, AuditLogAction.overwrite_update: AuditLogActionCategory.update,
AuditLogAction.overwrite_delete: AuditLogActionCategory.delete, AuditLogAction.overwrite_delete: AuditLogActionCategory.delete,
AuditLogAction.kick: None, AuditLogAction.kick: None,
AuditLogAction.member_prune: None, AuditLogAction.member_prune: None,
AuditLogAction.ban: None, AuditLogAction.ban: None,
AuditLogAction.unban: None, AuditLogAction.unban: None,
AuditLogAction.member_update: AuditLogActionCategory.update, AuditLogAction.member_update: AuditLogActionCategory.update,
AuditLogAction.member_role_update: AuditLogActionCategory.update, AuditLogAction.member_role_update: AuditLogActionCategory.update,
AuditLogAction.member_move: None, AuditLogAction.member_move: None,
AuditLogAction.member_disconnect: None, AuditLogAction.member_disconnect: None,
AuditLogAction.bot_add: None, AuditLogAction.bot_add: None,
AuditLogAction.role_create: AuditLogActionCategory.create, AuditLogAction.role_create: AuditLogActionCategory.create,
AuditLogAction.role_update: AuditLogActionCategory.update, AuditLogAction.role_update: AuditLogActionCategory.update,
AuditLogAction.role_delete: AuditLogActionCategory.delete, AuditLogAction.role_delete: AuditLogActionCategory.delete,
AuditLogAction.invite_create: AuditLogActionCategory.create, AuditLogAction.invite_create: AuditLogActionCategory.create,
AuditLogAction.invite_update: AuditLogActionCategory.update, AuditLogAction.invite_update: AuditLogActionCategory.update,
AuditLogAction.invite_delete: AuditLogActionCategory.delete, AuditLogAction.invite_delete: AuditLogActionCategory.delete,
AuditLogAction.webhook_create: AuditLogActionCategory.create, AuditLogAction.webhook_create: AuditLogActionCategory.create,
AuditLogAction.webhook_update: AuditLogActionCategory.update, AuditLogAction.webhook_update: AuditLogActionCategory.update,
AuditLogAction.webhook_delete: AuditLogActionCategory.delete, AuditLogAction.webhook_delete: AuditLogActionCategory.delete,
AuditLogAction.emoji_create: AuditLogActionCategory.create, AuditLogAction.emoji_create: AuditLogActionCategory.create,
AuditLogAction.emoji_update: AuditLogActionCategory.update, AuditLogAction.emoji_update: AuditLogActionCategory.update,
AuditLogAction.emoji_delete: AuditLogActionCategory.delete, AuditLogAction.emoji_delete: AuditLogActionCategory.delete,
AuditLogAction.message_delete: AuditLogActionCategory.delete, AuditLogAction.message_delete: AuditLogActionCategory.delete,
AuditLogAction.message_bulk_delete: AuditLogActionCategory.delete, AuditLogAction.message_bulk_delete: AuditLogActionCategory.delete,
AuditLogAction.message_pin: None, AuditLogAction.message_pin: None,
AuditLogAction.message_unpin: None, AuditLogAction.message_unpin: None,
AuditLogAction.integration_create: AuditLogActionCategory.create, AuditLogAction.integration_create: AuditLogActionCategory.create,
AuditLogAction.integration_update: AuditLogActionCategory.update, AuditLogAction.integration_update: AuditLogActionCategory.update,
AuditLogAction.integration_delete: AuditLogActionCategory.delete, AuditLogAction.integration_delete: AuditLogActionCategory.delete,
AuditLogAction.stage_instance_create: AuditLogActionCategory.create, AuditLogAction.stage_instance_create: AuditLogActionCategory.create,
AuditLogAction.stage_instance_update: AuditLogActionCategory.update, AuditLogAction.stage_instance_update: AuditLogActionCategory.update,
AuditLogAction.stage_instance_delete: AuditLogActionCategory.delete, AuditLogAction.stage_instance_delete: AuditLogActionCategory.delete,
AuditLogAction.sticker_create: AuditLogActionCategory.create, AuditLogAction.sticker_create: AuditLogActionCategory.create,
AuditLogAction.sticker_update: AuditLogActionCategory.update, AuditLogAction.sticker_update: AuditLogActionCategory.update,
AuditLogAction.sticker_delete: AuditLogActionCategory.delete, AuditLogAction.sticker_delete: AuditLogActionCategory.delete,
AuditLogAction.scheduled_event_create: AuditLogActionCategory.create, AuditLogAction.scheduled_event_create: AuditLogActionCategory.create,
AuditLogAction.scheduled_event_update: AuditLogActionCategory.update, AuditLogAction.scheduled_event_update: AuditLogActionCategory.update,
AuditLogAction.scheduled_event_delete: AuditLogActionCategory.delete, AuditLogAction.scheduled_event_delete: AuditLogActionCategory.delete,
AuditLogAction.thread_create: AuditLogActionCategory.create, AuditLogAction.thread_create: AuditLogActionCategory.create,
AuditLogAction.thread_delete: AuditLogActionCategory.delete, AuditLogAction.thread_delete: AuditLogActionCategory.delete,
AuditLogAction.thread_update: AuditLogActionCategory.update, AuditLogAction.thread_update: AuditLogActionCategory.update,
AuditLogAction.app_command_permission_update: AuditLogActionCategory.update, AuditLogAction.app_command_permission_update: AuditLogActionCategory.update,
AuditLogAction.automod_rule_create: AuditLogActionCategory.create, AuditLogAction.automod_rule_create: AuditLogActionCategory.create,
AuditLogAction.automod_rule_update: AuditLogActionCategory.update, AuditLogAction.automod_rule_update: AuditLogActionCategory.update,
AuditLogAction.automod_rule_delete: AuditLogActionCategory.delete, AuditLogAction.automod_rule_delete: AuditLogActionCategory.delete,
AuditLogAction.automod_block_message: None, AuditLogAction.automod_block_message: None,
AuditLogAction.automod_flag_message: None, AuditLogAction.automod_flag_message: None,
AuditLogAction.automod_timeout_member: None, AuditLogAction.automod_timeout_member: None,
AuditLogAction.creator_monetization_request_created: None,
AuditLogAction.creator_monetization_terms_accepted: None,
} }
# fmt: on # fmt: on
return lookup[self] return lookup[self]
@ -471,6 +475,8 @@ class AuditLogAction(Enum):
return 'auto_moderation' return 'auto_moderation'
elif v < 146: elif v < 146:
return 'user' return 'user'
elif v < 152:
return 'creator_monetization'
class UserFlags(Enum): class UserFlags(Enum):

2
discord/types/audit_log.py

@ -93,6 +93,8 @@ AuditLogEvent = Literal[
143, 143,
144, 144,
145, 145,
150,
151,
] ]

12
docs/api.rst

@ -2799,6 +2799,18 @@ of :class:`enum.Enum`.
.. versionadded:: 2.1 .. versionadded:: 2.1
.. attribute:: creator_monetization_request_created
A request to monetize the server was created.
.. versionadded:: 2.4
.. attribute:: creator_monetization_terms_accepted
The terms and conditions for creator monetization were accepted.
.. versionadded:: 2.4
.. class:: AuditLogActionCategory .. class:: AuditLogActionCategory
Represents the category that the :class:`AuditLogAction` belongs to. Represents the category that the :class:`AuditLogAction` belongs to.

Loading…
Cancel
Save