Repository: Rapptz/discord.py
File: discord/automod.py (Python)

Code before:
            return cls(duration=datetime.timedelta(seconds=duration_seconds))
        elif data['type'] == AutoModRuleActionType.send_alert_message.value:
            channel_id = int(data['metadata']['channel_id'])
            return cls(channel_id=channel_id)
        return cls()

    def to_dict(self) -> Dict[str, Any]:
        ret = {'type': self.type.value, 'metadata': {}}
        if self.type is AutoModRuleActionType.timeout:
            ret['metadata'] = {'duration_seconds': int(self.duration.total_seconds())}  # type: ignore # duration cannot be None here
        elif self.type is AutoModRuleActionType.send_alert_message:
            ret['metadata'] = {'channel_id': str(self.channel_id)}
        return ret


class AutoModTrigger:
    r"""Represents a trigger for an auto moderation rule.

    The following table illustrates relevant attributes for each :class:`AutoModRuleTriggerType`:

    +-----------------------------------------------+--------------------------------------+
    |                    Type                       |              Attributes              |
    +===============================================+======================================+
    | :attr:`AutoModRuleTriggerType.keyword`        | :attr:`keyword_filter`               |
    +-----------------------------------------------+--------------------------------------+
    | :attr:`AutoModRuleTriggerType.harmful_link`   |                                      |
    +-----------------------------------------------+--------------------------------------+
    | :attr:`AutoModRuleTriggerType.spam`           |                                      |
    +-----------------------------------------------+--------------------------------------+
    | :attr:`AutoModRuleTriggerType.keyword_preset` | :attr:`presets`\, :attr:`allow_list` |
    +-----------------------------------------------+--------------------------------------+
    | :attr:`AutoModRuleTriggerType.mention_spam`   | :attr:`mention_limit`                |
    +-----------------------------------------------+--------------------------------------+

    .. versionadded:: 2.0

    Attributes
    -----------
    type: :class:`AutoModRuleTriggerType`
        The type of trigger.
    keyword_filter: List[:class:`str`]
        The list of strings that will trigger the keyword filter.
    presets: :class:`AutoModPresets`
        The presets used with the preset keyword filter.
    allow_list: List[:class:`str`]
        The list of words that are exempt from the commonly flagged words.
    mention_limit: :class:`int`
        The total number of user and role mentions a message can contain.
        Has a maximum of 50.
    """


Review comment (suggestion):
This trigger type is apparently deprecated/removed and is on by default according to DAPI docs so it might be worth removing this before pypi release

Code after:
            return cls(duration=datetime.timedelta(seconds=duration_seconds))
        elif data['type'] == AutoModRuleActionType.send_alert_message.value:
            channel_id = int(data['metadata']['channel_id'])
            return cls(channel_id=channel_id)
        return cls()

    def to_dict(self) -> Dict[str, Any]:
        ret = {'type': self.type.value, 'metadata': {}}
        if self.type is AutoModRuleActionType.timeout:
            ret['metadata'] = {'duration_seconds': int(self.duration.total_seconds())}  # type: ignore # duration cannot be None here
        elif self.type is AutoModRuleActionType.send_alert_message:
            ret['metadata'] = {'channel_id': str(self.channel_id)}
        return ret


class AutoModTrigger:
    r"""Represents a trigger for an auto moderation rule.

    The following table illustrates relevant attributes for each :class:`AutoModRuleTriggerType`:

    +-----------------------------------------------+--------------------------------------+
    |                    Type                       |              Attributes              |
    +===============================================+======================================+
    | :attr:`AutoModRuleTriggerType.keyword`        | :attr:`keyword_filter`               |
    +-----------------------------------------------+--------------------------------------+
    | :attr:`AutoModRuleTriggerType.spam`           |                                      |
    +-----------------------------------------------+--------------------------------------+
    | :attr:`AutoModRuleTriggerType.keyword_preset` | :attr:`presets`\, :attr:`allow_list` |
    +-----------------------------------------------+--------------------------------------+
    | :attr:`AutoModRuleTriggerType.mention_spam`   | :attr:`mention_limit`                |
    +-----------------------------------------------+--------------------------------------+

    .. versionadded:: 2.0

    Attributes
    -----------
    type: :class:`AutoModRuleTriggerType`
        The type of trigger.
    keyword_filter: List[:class:`str`]
        The list of strings that will trigger the keyword filter.
    presets: :class:`AutoModPresets`
        The presets used with the preset keyword filter.
    allow_list: List[:class:`str`]
        The list of words that are exempt from the commonly flagged words.
    mention_limit: :class:`int`
        The total number of user and role mentions a message can contain.
        Has a maximum of 50.
    """

    __slots__ = (
        'type',