mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-10-22 16:32:59 +00:00
Implement AutoMod
This commit is contained in:
249
docs/api.rst
249
docs/api.rst
@@ -203,6 +203,53 @@ to handle it, which defaults to logging the traceback and ignoring the exception
|
||||
errors. In order to turn a function into a coroutine they must be ``async def``
|
||||
functions.
|
||||
|
||||
AutoMod
|
||||
~~~~~~~
|
||||
|
||||
.. function:: on_automod_rule_create(rule)
|
||||
|
||||
Called when a :class:`AutoModRule` is created.
|
||||
|
||||
This requires :attr:`Intents.auto_moderation_configuration` to be enabled.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
:param rule: The rule that was created.
|
||||
:type rule: :class:`AutoModRule`
|
||||
|
||||
.. function:: on_automod_rule_update(rule)
|
||||
|
||||
Called when a :class:`AutoModRule` is updated.
|
||||
|
||||
This requires :attr:`Intents.auto_moderation_configuration` to be enabled.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
:param rule: The rule that was updated.
|
||||
:type rule: :class:`AutoModRule`
|
||||
|
||||
.. function:: on_automod_rule_delete(rule)
|
||||
|
||||
Called when a :class:`AutoModRule` is deleted.
|
||||
|
||||
This requires :attr:`Intents.auto_moderation_configuration` to be enabled.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
:param rule: The rule that was deleted.
|
||||
:type rule: :class:`AutoModRule`
|
||||
|
||||
.. function:: on_automod_action(execution)
|
||||
|
||||
Called when a :class:`AutoModAction` is created/performed.
|
||||
|
||||
This requires :attr:`Intents.auto_moderation_execution` to be enabled.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
:param execution: The rule execution that was performed.
|
||||
:type execution: :class:`AutoModAction`
|
||||
|
||||
Channels
|
||||
~~~~~~~~~
|
||||
|
||||
@@ -2525,6 +2572,84 @@ of :class:`enum.Enum`.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
.. attribute:: automod_rule_create
|
||||
|
||||
An automod rule was created.
|
||||
|
||||
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
||||
a :class:`Object` with the ID of the automod rule that was created.
|
||||
|
||||
Possible attributes for :class:`AuditLogDiff`:
|
||||
|
||||
- :attr:`~AuditLogDiff.name`
|
||||
- :attr:`~AuditLogDiff.enabled`
|
||||
- :attr:`~AuditLogDiff.event_type`
|
||||
- :attr:`~AuditLogDiff.trigger_type`
|
||||
- :attr:`~AuditLogDiff.trigger_metadata`
|
||||
- :attr:`~AuditLogDiff.actions`
|
||||
- :attr:`~AuditLogDiff.exempt_roles`
|
||||
- :attr:`~AuditLogDiff.exempt_channels`
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
.. attribute:: automod_role_update
|
||||
|
||||
An automod rule was updated.
|
||||
|
||||
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
||||
a :class:`Object` with the ID of the automod rule that was updated.
|
||||
|
||||
Possible attributes for :class:`AuditLogDiff`:
|
||||
|
||||
- :attr:`~AuditLogDiff.name`
|
||||
- :attr:`~AuditLogDiff.enabled`
|
||||
- :attr:`~AuditLogDiff.event_type`
|
||||
- :attr:`~AuditLogDiff.trigger_type`
|
||||
- :attr:`~AuditLogDiff.trigger_metadata`
|
||||
- :attr:`~AuditLogDiff.actions`
|
||||
- :attr:`~AuditLogDiff.exempt_roles`
|
||||
- :attr:`~AuditLogDiff.exempt_channels`
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
.. attribute:: automod_rule_delete
|
||||
|
||||
An automod rule was deleted.
|
||||
|
||||
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
||||
a :class:`Object` with the ID of the automod rule that was deleted.
|
||||
|
||||
Possible attributes for :class:`AuditLogDiff`:
|
||||
|
||||
- :attr:`~AuditLogDiff.name`
|
||||
- :attr:`~AuditLogDiff.enabled`
|
||||
- :attr:`~AuditLogDiff.event_type`
|
||||
- :attr:`~AuditLogDiff.trigger_type`
|
||||
- :attr:`~AuditLogDiff.trigger_metadata`
|
||||
- :attr:`~AuditLogDiff.actions`
|
||||
- :attr:`~AuditLogDiff.exempt_roles`
|
||||
- :attr:`~AuditLogDiff.exempt_channels`
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
.. attribute:: automod_block_message
|
||||
|
||||
An automod rule blocked a message from being sent.
|
||||
|
||||
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 3 attributes:
|
||||
|
||||
- ``automod_rule_name``: The name of the automod rule that was triggered.
|
||||
- ``automod_rule_trigger``: A :class:`AutoModRuleTriggerType` representation of the rule type that was triggered.
|
||||
- ``channel``: The channel in which the automod rule was triggered.
|
||||
|
||||
When this is the action, :attr:`AuditLogEntry.changes` is empty.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
.. class:: AuditLogActionCategory
|
||||
|
||||
Represents the category that the :class:`AuditLogAction` belongs to.
|
||||
@@ -2950,6 +3075,56 @@ of :class:`enum.Enum`.
|
||||
|
||||
An alias for :attr:`completed`.
|
||||
|
||||
.. class:: AutoModRuleTriggerType
|
||||
|
||||
Represents the trigger type of an auto mod rule.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
.. attribute:: keyword
|
||||
|
||||
The rule will trigger when a keyword is mentioned.
|
||||
|
||||
.. attribute:: harmful_link
|
||||
|
||||
The rule will trigger when a harmful link is posted.
|
||||
|
||||
.. attribute:: spam
|
||||
|
||||
The rule will trigger when a spam message is posted.
|
||||
|
||||
.. attribute:: keyword_preset
|
||||
|
||||
The rule will trigger when something triggers based on the set keyword preset types.
|
||||
|
||||
.. class:: AutoModRuleEventType
|
||||
|
||||
Represents the event type of an auto mod rule.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
.. attribute:: message_send
|
||||
|
||||
The rule will trigger when a message is sent.
|
||||
|
||||
.. class:: AutoModRuleActionType
|
||||
|
||||
Represents the action type of an auto mod rule.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
.. attribute:: block_message
|
||||
|
||||
The rule will block a message from being sent.
|
||||
|
||||
.. attribute:: send_alert_message
|
||||
|
||||
The rule will send an alert message to a predefined channel.
|
||||
|
||||
.. attribute:: timeout
|
||||
|
||||
The rule will timeout a user.
|
||||
|
||||
.. _discord-api-audit-logs:
|
||||
|
||||
Audit Log Data
|
||||
@@ -3543,6 +3718,48 @@ AuditLogDiff
|
||||
|
||||
:type: :class:`~discord.app_commands.AppCommandPermissions`
|
||||
|
||||
.. attribute:: enabled
|
||||
|
||||
Whether the automod rule is active or not.
|
||||
|
||||
:type: :class:`bool`
|
||||
|
||||
.. attribute:: event_type
|
||||
|
||||
The event type for triggering the automod rule.
|
||||
|
||||
:type: :class:`str`
|
||||
|
||||
.. attribute:: trigger_type
|
||||
|
||||
The trigger type for the automod rule.
|
||||
|
||||
:type: :class:`AutoModRuleTriggerType`
|
||||
|
||||
.. attribute:: trigger_metadata
|
||||
|
||||
The trigger metadata for the automod rule.
|
||||
|
||||
:type: Dict[:class:`str`, Any]
|
||||
|
||||
.. attribute:: actions
|
||||
|
||||
The actions to take when an automod rule is triggered.
|
||||
|
||||
:type: List[Dict[:class:`str`, Any]]
|
||||
|
||||
.. attribute:: exempt_roles
|
||||
|
||||
The list of roles that are exempt from the automod rule.
|
||||
|
||||
:type: List[:class:`str`]
|
||||
|
||||
.. attribute:: exempt_channels
|
||||
|
||||
The list of channels that are exempt from the automod rule.
|
||||
|
||||
:type: List[:class:`str`]
|
||||
|
||||
.. this is currently missing the following keys: reason and application_id
|
||||
I'm not sure how to about porting these
|
||||
|
||||
@@ -3699,6 +3916,15 @@ User
|
||||
.. automethod:: typing
|
||||
:async-with:
|
||||
|
||||
AutoMod
|
||||
~~~~~~~
|
||||
|
||||
.. autoclass:: AutoModRule()
|
||||
:members:
|
||||
|
||||
.. autoclass:: AutoModAction()
|
||||
:members:
|
||||
|
||||
Attachment
|
||||
~~~~~~~~~~~
|
||||
|
||||
@@ -4295,6 +4521,29 @@ ChannelFlags
|
||||
.. autoclass:: ChannelFlags
|
||||
:members:
|
||||
|
||||
AutoModPresets
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. attributetable:: AutoModPresets
|
||||
|
||||
.. autoclass:: AutoModPresets
|
||||
:members:
|
||||
|
||||
AutoModRuleAction
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. attributetable:: AutoModRuleAction
|
||||
|
||||
.. autoclass:: AutoModRuleAction
|
||||
:members:
|
||||
|
||||
AutoModTrigger
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. attributetable:: AutoModTrigger
|
||||
|
||||
.. autoclass:: AutoModTrigger
|
||||
:members:
|
||||
|
||||
File
|
||||
~~~~~
|
||||
|
Reference in New Issue
Block a user