Repository: hikari-py/hikari
Pull request #1702 (2023-08-30 15:03:54)

Fix attachments not being removed in message edits
### Summary
<!-- Small summary of the merge request -->

### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [x] I have run `nox` and all the pipelines have passed.
- [x] I have made unittests according to the code I have added/modified/deleted.

### Related issues
<!--
To mention an issue use `#issue-id` and to mention a merge request use `!merge-request-id`
To close/fix an issue use `Close #issue-id` or `Fix #issue-id` (depending on the merge request)
-->


FasterSpeeding: if any message edit endpoint isn't properly handling `None` for `attachmnts` that should be reported to discord

Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 11ff3da3..ce355fde 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -23,7 +23,7 @@ jobs:
 
     steps:
       - name: Checkout repository
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
 
       - name: Setup python
         uses: actions/setup-python@v4
@@ -66,7 +66,7 @@ jobs:
 
     steps:
       - name: Checkout repository
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
 
       - name: Setup python
         uses: actions/setup-python@v4
@@ -97,7 +97,7 @@ jobs:
 
     steps:
       - name: Checkout repository
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
 
       - name: Setup python
         uses: actions/setup-python@v4
@@ -154,7 +154,7 @@ jobs:
 
     steps:
       - name: Checkout repository
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
 
       - name: Setup python
         uses: actions/setup-python@v4
@@ -171,7 +171,7 @@ jobs:
 
     steps:
       - name: Checkout repository
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
 
       - name: Setup python
         uses: actions/setup-python@v4
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index edda10ab..19e06cba 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -19,7 +19,7 @@ jobs:
 
     steps:
     - name: Checkout repository
-      uses: actions/checkout@v3
+      uses: actions/checkout@v4
 
     - name: Initialize CodeQL
       uses: github/codeql-action/init@v2
diff --git a/.github/workflows/fragments-check.yml b/.github/workflows/fragments-check.yml
index cececdc2..f3866844 100644
--- a/.github/workflows/fragments-check.yml
+++ b/.github/workflows/fragments-check.yml
@@ -13,7 +13,7 @@ jobs:
 
     steps:
       - name: Checkout repository
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
         with:
           # `towncrier check` runs `git diff --name-only origin/main...`, which
           # needs a non-shallow clone.
diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml
index 99e7bb2b..cf52a341 100644
--- a/.github/workflows/prepare-release.yml
+++ b/.github/workflows/prepare-release.yml
@@ -22,7 +22,7 @@ jobs:
           private_key: ${{ secrets.PRIVATE_KEY }}
 
       - name: Checkout repository
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
         with:
           token: ${{ steps.generate_token.outputs.token }}
 
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 7d84b6f0..8c49d2cf 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -17,7 +17,7 @@ jobs:
           private_key: ${{ secrets.PRIVATE_KEY }}
 
       - name: Checkout repository
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
         with:
           token: ${{ steps.generate_token.outputs.token }}
 
diff --git a/changes/1702.bugfix.md b/changes/1702.bugfix.md
new file mode 100644
index 00000000..a686079c
--- /dev/null
+++ b/changes/1702.bugfix.md
@@ -0,0 +1,1 @@
+Fix attachments not being removed in message edits when `attachment` or `attachments` is `None`
diff --git a/changes/1705.feature.md b/changes/1705.feature.md
new file mode 100644
index 00000000..2d52cdd0
--- /dev/null
+++ b/changes/1705.feature.md
@@ -0,0 +1,1 @@
+Add missing Audit Log event types to `AuditLogEventType`
diff --git a/dev-requirements/pyright.txt b/dev-requirements/pyright.txt
index f6bf0b7d..ddb08a0b 100644
--- a/dev-requirements/pyright.txt
+++ b/dev-requirements/pyright.txt
@@ -1,1 +1,1 @@
-pyright==1.1.324
+pyright==1.1.325
diff --git a/dev-requirements/sphinx.txt b/dev-requirements/sphinx.txt
index a0113da2..b5158aec 100644
--- a/dev-requirements/sphinx.txt
+++ b/dev-requirements/sphinx.txt
@@ -1,4 +1,4 @@
-sphinx==7.2.4
+sphinx==7.2.5
 
 # Theme
 furo==2023.8.19
diff --git a/hikari/audit_logs.py b/hikari/audit_logs.py
index a9c09da8..6b933a50 100644
--- a/hikari/audit_logs.py
+++ b/hikari/audit_logs.py
@@ -334,6 +334,11 @@ class AuditLogEventType(int, enums.Enum):
     GUILD_SCHEDULED_EVENT_UPDATE = 101
     GUILD_SCHEDULED_EVENT_DELETE = 102
     APPLICATION_COMMAND_PERMISSION_UPDATE = 121
+    THREAD_CREATE = 110
+    THREAD_UPDATE = 111
+    THREAD_DELETE = 112
+    CREATOR_MONETIZATION_REQUEST_CREATED = 150
+    CREATOR_MONETIZATION_TERMS_ACCEPTED = 151
 
 
 @attrs.define(hash=False, kw_only=True, weakref_slot=False)
diff --git a/hikari/impl/rest.py b/hikari/impl/rest.py
index 024704ff..fbf8ae43 100644
--- a/hikari/impl/rest.py
+++ b/hikari/impl/rest.py
@@ -1484,7 +1484,7 @@ def _build_message_payload(  # noqa: C901- Function too complex
             body.put("attachments", attachments_payload)
 
         elif attachment is None or attachments is None:
-            body.put("attachments", None)
+            body.put("attachments", [])
 
         return body, form_builder
 


Test patch:
diff --git a/tests/hikari/impl/test_rest.py b/tests/hikari/impl/test_rest.py
index 15132aa7..142f043f 100644
--- a/tests/hikari/impl/test_rest.py
+++ b/tests/hikari/impl/test_rest.py
@@ -1166,7 +1166,7 @@ def test__build_message_payload_with_undefined_args(self, rest_client):
             undefined.UNDEFINED, undefined.UNDEFINED, undefined.UNDEFINED, undefined.UNDEFINED
         )
 
-    @pytest.mark.parametrize("args", [("embeds", "components"), ("embed", "component")])
+    @pytest.mark.parametrize("args", [("embeds", "components", "attachments"), ("embed", "component", "attachment")])
     def test__build_message_payload_with_None_args(self, rest_client, args):
         kwargs = {}
         for arg in args:
@@ -1177,7 +1177,7 @@ def test__build_message_payload_with_None_args(self, rest_client, args):
         ) as generate_allowed_mentions:
             body, form = rest_client._build_message_payload(**kwargs)
 
-        assert body == {"embeds": [], "components": [], "allowed_mentions": {"allowed_mentions": 1}}
+        assert body == {"embeds": [], "components": [], "attachments": [], "allowed_mentions": {"allowed_mentions": 1}}
         assert form is None
 
         generate_allowed_mentions.assert_called_once_with(