Repository: interactions-py/interactions.py

Issue:
Cannot remove embeds nor components from a message
[`ComponentContext.edit_origin`](https://github.com/discord-py-slash-commands/discord-py-interactions/blob/83937fefc297c3062c018381ef5c7751225b5d9b/discord_slash/context.py#L369) and `SlashMessage.edit` ([`SlashMessage._slash_edit`](https://github.com/discord-py-slash-commands/discord-py-interactions/blob/a7f468b66137726a2535a9d62177f6e25a8f8d2f/discord_slash/model.py#L492)) do not support using an empty list `[]` for the `embeds` nor `components` keyword argument, which prevents removing them from a message.


Discussion:
Going to add onto this - this seems to be due to how the library check for equality and the existence of kwargs. Empty lists are falsey values in Python, and since the library does `if kwarg.get("kwarg")` in order to see if a kwarg exists, this means that even if the kwarg exists, since [] is falsey, the library also mistakenly thinks it's false and so doesn't exist.

This can be solved simply by using `is not None` for those checks instead, Might make the PR myself to fix this, who knows.

Resolving patch:
diff --git a/discord_slash/context.py b/discord_slash/context.py
--- a/discord_slash/context.py
+++ b/discord_slash/context.py
@@ -373,33 +373,57 @@ async def edit_origin(self, **fields):
         """
         _resp = {}
 
-        content = fields.get("content")
-        if content:
-            _resp["content"] = str(content)
+        try:
+            content = fields["content"]
+        except KeyError:
+            pass
+        else:
+            if content is not None:
+                content = str(content)
+            _resp["content"] = content
+
+        try:
+            components = fields["components"]
+        except KeyError:
+            pass
+        else:
+            if components is None:
+                _resp["components"] = []
+            else:
+                _resp["components"] = components
+
+        try:
+            embeds = fields["embeds"]
+        except KeyError:
+            # Nope
+            pass
+        else:
+            if not isinstance(embeds, list):
+                raise error.IncorrectFormat("Provide a list of embeds.")
+            if len(embeds) > 10:
+                raise error.IncorrectFormat("Do not provide more than 10 embeds.")
+            _resp["embeds"] = [e.to_dict() for e in embeds]
+
+        try:
+            embed = fields["embed"]
+        except KeyError:
+            pass
+        else:
+            if "embeds" in _resp:
+                raise error.IncorrectFormat("You can't use both `embed` and `embeds`!")
+
+            if embed is None:
+                _resp["embeds"] = []
+            else:
+                _resp["embeds"] = [embed.to_dict()]
 
-        embed = fields.get("embed")
-        embeds = fields.get("embeds")
         file = fields.get("file")
         files = fields.get("files")
-        components = fields.get("components")
 
-        if components:
-            _resp["components"] = components
-
-        if embed and embeds:
-            raise error.IncorrectFormat("You can't use both `embed` and `embeds`!")
-        if file and files:
+        if files is not None and file is not None:
             raise error.IncorrectFormat("You can't use both `file` and `files`!")
         if file:
             files = [file]
-        if embed:
-            embeds = [embed]
-        if embeds:
-            if not isinstance(embeds, list):
-                raise error.IncorrectFormat("Provide a list of embeds.")
-            elif len(embeds) > 10:
-                raise error.IncorrectFormat("Do not provide more than 10 embeds.")
-            _resp["embeds"] = [x.to_dict() for x in embeds]
 
         allowed_mentions = fields.get("allowed_mentions")
         _resp["allowed_mentions"] = (
diff --git a/discord_slash/model.py b/discord_slash/model.py
--- a/discord_slash/model.py
+++ b/discord_slash/model.py
@@ -495,33 +495,57 @@ async def _slash_edit(self, **fields):
         """
         _resp = {}
 
-        content = fields.get("content")
-        if content:
-            _resp["content"] = str(content)
+        try:
+            content = fields["content"]
+        except KeyError:
+            pass
+        else:
+            if content is not None:
+                content = str(content)
+            _resp["content"] = content
+
+        try:
+            components = fields["components"]
+        except KeyError:
+            pass
+        else:
+            if components is None:
+                _resp["components"] = []
+            else:
+                _resp["components"] = components
+
+        try:
+            embeds = fields["embeds"]
+        except KeyError:
+            # Nope
+            pass
+        else:
+            if not isinstance(embeds, list):
+                raise error.IncorrectFormat("Provide a list of embeds.")
+            if len(embeds) > 10:
+                raise error.IncorrectFormat("Do not provide more than 10 embeds.")
+            _resp["embeds"] = [e.to_dict() for e in embeds]
+
+        try:
+            embed = fields["embed"]
+        except KeyError:
+            pass
+        else:
+            if "embeds" in _resp:
+                raise error.IncorrectFormat("You can't use both `embed` and `embeds`!")
+
+            if embed is None:
+                _resp["embeds"] = []
+            else:
+                _resp["embeds"] = [embed.to_dict()]
 
-        embed = fields.get("embed")
-        embeds = fields.get("embeds")
         file = fields.get("file")
         files = fields.get("files")
-        components = fields.get("components")
 
-        if components:
-            _resp["components"] = components
-
-        if embed and embeds:
-            raise error.IncorrectFormat("You can't use both `embed` and `embeds`!")
-        if file and files:
+        if files is not None and file is not None:
             raise error.IncorrectFormat("You can't use both `file` and `files`!")
         if file:
             files = [file]
-        if embed:
-            embeds = [embed]
-        if embeds:
-            if not isinstance(embeds, list):
-                raise error.IncorrectFormat("Provide a list of embeds.")
-            elif len(embeds) > 10:
-                raise error.IncorrectFormat("Do not provide more than 10 embeds.")
-            _resp["embeds"] = [x.to_dict() for x in embeds]
 
         allowed_mentions = fields.get("allowed_mentions")
         _resp["allowed_mentions"] = (


Test patch: