Browse Source

Merge branch 'Rapptz:master' into voice-messages

pull/10230/head
blord0 1 month ago
committed by GitHub
parent
commit
0f1ded6e0e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 13
      discord/audit_logs.py
  2. 4
      discord/enums.py
  3. 10
      discord/flags.py
  4. 6
      discord/state.py
  5. 1
      discord/types/audit_log.py
  6. 2
      discord/webhook/async_.py
  7. 17
      docs/api.rst

13
discord/audit_logs.py

@ -614,6 +614,11 @@ class _AuditLogProxyAutoModAction(_AuditLogProxy):
channel: Optional[Union[abc.GuildChannel, Thread]] channel: Optional[Union[abc.GuildChannel, Thread]]
class _AuditLogProxyAutoModActionQuarantineUser(_AuditLogProxy):
automod_rule_name: str
automod_rule_trigger_type: str
class _AuditLogProxyMemberKickOrMemberRoleUpdate(_AuditLogProxy): class _AuditLogProxyMemberKickOrMemberRoleUpdate(_AuditLogProxy):
integration_type: Optional[str] integration_type: Optional[str]
@ -704,6 +709,7 @@ class AuditLogEntry(Hashable):
_AuditLogProxyStageInstanceAction, _AuditLogProxyStageInstanceAction,
_AuditLogProxyMessageBulkDelete, _AuditLogProxyMessageBulkDelete,
_AuditLogProxyAutoModAction, _AuditLogProxyAutoModAction,
_AuditLogProxyAutoModActionQuarantineUser,
_AuditLogProxyMemberKickOrMemberRoleUpdate, _AuditLogProxyMemberKickOrMemberRoleUpdate,
Member, User, None, PartialIntegration, Member, User, None, PartialIntegration,
Role, Object Role, Object
@ -759,6 +765,13 @@ class AuditLogEntry(Hashable):
), ),
channel=channel, channel=channel,
) )
elif self.action is enums.AuditLogAction.automod_quarantine_user:
self.extra = _AuditLogProxyAutoModActionQuarantineUser(
automod_rule_name=extra['auto_moderation_rule_name'],
automod_rule_trigger_type=enums.try_enum(
enums.AutoModRuleTriggerType, extra['auto_moderation_rule_trigger_type']
),
)
elif self.action.name.startswith('overwrite_'): elif self.action.name.startswith('overwrite_'):
# the overwrite_ actions have a dict with some information # the overwrite_ actions have a dict with some information

4
discord/enums.py

@ -398,6 +398,7 @@ class AuditLogAction(Enum):
automod_block_message = 143 automod_block_message = 143
automod_flag_message = 144 automod_flag_message = 144
automod_timeout_member = 145 automod_timeout_member = 145
automod_quarantine_user = 146
creator_monetization_request_created = 150 creator_monetization_request_created = 150
creator_monetization_terms_accepted = 151 creator_monetization_terms_accepted = 151
# fmt: on # fmt: on
@ -460,6 +461,7 @@ class AuditLogAction(Enum):
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.automod_quarantine_user: None,
AuditLogAction.creator_monetization_request_created: None, AuditLogAction.creator_monetization_request_created: None,
AuditLogAction.creator_monetization_terms_accepted: None, AuditLogAction.creator_monetization_terms_accepted: None,
AuditLogAction.soundboard_sound_create: AuditLogActionCategory.create, AuditLogAction.soundboard_sound_create: AuditLogActionCategory.create,
@ -506,7 +508,7 @@ class AuditLogAction(Enum):
return 'integration_or_app_command' return 'integration_or_app_command'
elif 139 < v < 143: elif 139 < v < 143:
return 'auto_moderation' return 'auto_moderation'
elif v < 146: elif v < 147:
return 'user' return 'user'
elif v < 152: elif v < 152:
return 'creator_monetization' return 'creator_monetization'

10
discord/flags.py

@ -2094,6 +2094,15 @@ class MemberFlags(BaseFlags):
""" """
return 1 << 7 return 1 << 7
@flag_value
def automod_quarantined_guild_tag(self):
""":class:`bool`: Returns ``True`` if the member's guild tag has been
blocked by AutoMod.
.. versionadded:: 2.6
"""
return 1 << 10
@flag_value @flag_value
def dm_settings_upsell_acknowledged(self): def dm_settings_upsell_acknowledged(self):
""":class:`bool`: Returns ``True`` if the member has dismissed the DM settings upsell. """:class:`bool`: Returns ``True`` if the member has dismissed the DM settings upsell.
@ -2400,6 +2409,7 @@ class EmbedFlags(BaseFlags):
return 1 << 5 return 1 << 5
@fill_with_flags()
class InviteFlags(BaseFlags): class InviteFlags(BaseFlags):
r"""Wraps up the Discord Invite flags r"""Wraps up the Discord Invite flags

6
discord/state.py

@ -1101,6 +1101,12 @@ class ConnectionState(Generic[ClientT]):
_log.debug('GUILD_MEMBER_ADD referencing an unknown guild ID: %s. Discarding.', data['guild_id']) _log.debug('GUILD_MEMBER_ADD referencing an unknown guild ID: %s. Discarding.', data['guild_id'])
return return
member_id = int(data['user']['id'])
member = guild.get_member(member_id)
if member is not None:
_log.debug('GUILD_MEMBER_ADD referencing an already cached member ID: %s. Discarding.', member_id)
return
member = Member(guild=guild, data=data, state=self) member = Member(guild=guild, data=data, state=self)
if self.member_cache_flags.joined: if self.member_cache_flags.joined:
guild._add_member(member) guild._add_member(member)

1
discord/types/audit_log.py

@ -97,6 +97,7 @@ AuditLogEvent = Literal[
143, 143,
144, 144,
145, 145,
146,
150, 150,
151, 151,
] ]

2
discord/webhook/async_.py

@ -1872,7 +1872,7 @@ class Webhook(BaseWebhook):
if wait: if wait:
msg = self._create_message(data, thread=thread) msg = self._create_message(data, thread=thread)
if view is not MISSING and not view.is_finished(): if view is not MISSING and not view.is_finished() and view.is_dispatchable():
message_id = None if msg is None else msg.id message_id = None if msg is None else msg.id
self._state.store_view(view, message_id) self._state.store_view(view, message_id)

17
docs/api.rst

@ -3055,6 +3055,23 @@ of :class:`enum.Enum`.
.. versionadded:: 2.1 .. versionadded:: 2.1
.. attribute:: automod_quarantine_user
An automod rule quarantined a member.
When this is the action, the type of :attr:`~AuditLogEntry.target` is
a :class:`Member` with the ID of the person who triggered the automod rule.
When this is the action, the type of :attr:`~AuditLogEntry.extra` is
set to an unspecified proxy object with 2 attributes:
- ``automod_rule_name``: The name of the automod rule that was triggered.
- ``automod_rule_trigger_type``: A :class:`AutoModRuleTriggerType` representation of the rule type that was triggered.
When this is the action, :attr:`AuditLogEntry.changes` is empty.
.. versionadded:: 2.6
.. attribute:: creator_monetization_request_created .. attribute:: creator_monetization_request_created
A request to monetize the server was created. A request to monetize the server was created.

Loading…
Cancel
Save