Repository: Pycord-Development/pycord

Issue:
on_auto_moderation_rule_X events TypeError
### Summary

on_auto_moderation_rule_X events throw TypeErrors

### Reproduction Steps

Try to use the events.

### Minimal Reproducible Code

```python
@commands.Cog.listener()
async def on_auto_moderation_rule_create(self, rule):
    print(rule.guild.id)
```


### Expected Results

A usable guild object.

### Actual Results

TypeError: No '__dict__' attribute on 'AutoModRule' instance to cache 'guild' property

### Intents

auto_moderation_configuration, guilds, etc.

### System Information

Python v3.10.6-final
py-cord v2.4.None-final
aiohttp v3.8.3
Linux 5.15.0-67-generic #74-Ubuntu

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

_No response_


Discussion:
Please show the full traceback
![image](https://user-images.githubusercontent.com/12460903/225941643-e3bd2100-3620-45b5-90ef-87dfc129008d.png)

This may be of help?
https://github.com/Pycord-Development/pycord/blob/f8b4294ff06e0f700bcfe8c0ec13d0ec0085c7dd/discord/automod.py#L402-L405

Resolving patch:
diff --git a/discord/automod.py b/discord/automod.py
--- a/discord/automod.py
+++ b/discord/automod.py
@@ -76,6 +76,10 @@ class AutoModActionMetadata:
     timeout_duration: :class:`datetime.timedelta`
         How long the member that triggered the action should be timed out for.
         Only for actions of type :attr:`AutoModActionType.timeout`.
+    custom_message: :class:`str`
+        An additional message shown to members when their message is blocked.
+        Maximum 150 characters.
+        Only for actions of type :attr:`AutoModActionType.block_message`.
     """
 
     # maybe add a table of action types and attributes?
@@ -83,13 +87,18 @@ class AutoModActionMetadata:
     __slots__ = (
         "channel_id",
         "timeout_duration",
+        "custom_message",
     )
 
     def __init__(
-        self, channel_id: int = MISSING, timeout_duration: timedelta = MISSING
+        self,
+        channel_id: int = MISSING,
+        timeout_duration: timedelta = MISSING,
+        custom_message: str = MISSING,
     ):
         self.channel_id: int = channel_id
         self.timeout_duration: timedelta = timeout_duration
+        self.custom_message: str = custom_message
 
     def to_dict(self) -> dict:
         data = {}
@@ -100,6 +109,9 @@ def to_dict(self) -> dict:
         if self.timeout_duration is not MISSING:
             data["duration_seconds"] = self.timeout_duration.total_seconds()
 
+        if self.custom_message is not MISSING:
+            data["custom_message"] = self.custom_message
+
         return data
 
     @classmethod
@@ -113,12 +125,16 @@ def from_dict(cls, data: AutoModActionMetadataPayload):
             # might need an explicit int cast
             kwargs["timeout_duration"] = timedelta(seconds=duration_seconds)
 
+        if (custom_message := data.get("custom_message")) is not None:
+            kwargs["custom_message"] = custom_message
+
         return cls(**kwargs)
 
     def __repr__(self) -> str:
         repr_attrs = (
             "channel_id",
             "timeout_duration",
+            "custom_message",
         )
         inner = []
 
@@ -352,6 +368,7 @@ class AutoModRule(Hashable):
     """
 
     __slots__ = (
+        "__dict__",
         "_state",
         "id",
         "guild_id",
diff --git a/discord/types/automod.py b/discord/types/automod.py
--- a/discord/types/automod.py
+++ b/discord/types/automod.py
@@ -47,6 +47,7 @@ class AutoModTriggerMetadata(TypedDict, total=False):
 class AutoModActionMetadata(TypedDict, total=False):
     channel_id: Snowflake
     duration_seconds: int
+    custom_message: str
 
 
 class AutoModAction(TypedDict):


Test patch: