We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Editing SlashMessage should support multiple embeds
Calling `discord_slash.model.SlashMessage.edit` with an `embeds` kwarg does not work. However the official Discord API documentation says that it should be possible [when editing interaction messages](https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response).

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `discord_slash/model.py`
Content:
```
1 import asyncio
2 import discord
3 from enum import IntEnum
4 from contextlib import suppress
5 from inspect import iscoroutinefunction
6 from . import http
7 from . import error
8 
9 
10 class ChoiceData:
11     """
12     Command choice data object
13 
14     :ivar name: Name of the choice, this is what the user will see
15     :ivar value: Values of the choice, this is what discord will return to you
16     """
17 
18     def __init__(self, name, value):
19         self.name = name
20         self.value = value
21 
22     def __eq__(self, other):
23         return isinstance(other, ChoiceData) and self.__dict__ == other.__dict__
24 
25 
26 class OptionData:
27     """
28     Command option data object
29 
30     :ivar name: Name of the option.
31     :ivar description: Description of the option.
32     :ivar required: If the option is required.
33     :ivar choices: A list of :class:`ChoiceData`, cannot be present on subcommand groups
34     :ivar options: List of :class:`OptionData`, this will be present if it's a subcommand group
35     """
36 
37     def __init__(
38             self, name, description, required=False, choices=None, options=None, **kwargs
39     ):
40         self.name = name
41         self.description = description
42         self.type = kwargs.get("type")
43         if self.type is None:
44             raise error.IncorrectCommandData("type is required for options")
45         self.required = required
46         if choices is not None:
47             self.choices = []
48             for choice in choices:
49                 self.choices.append(ChoiceData(**choice))
50         else:
51             self.choices = None
52 
53         if self.type in (1, 2):
54             self.options = []
55             if options is not None:
56                 for option in options:
57                     self.options.append(OptionData(**option))
58             elif self.type == 2:
59                 raise error.IncorrectCommandData(
60                     "Options are required for subcommands / subcommand groups"
61                 )
62 
63     def __eq__(self, other):
64         return isinstance(other, OptionData) and self.__dict__ == other.__dict__
65 
66 
67 class CommandData:
68     """
69     Slash command data object
70 
71     :ivar name: Name of the command.
72     :ivar description: Description of the command.
73     :ivar options: List of :class:`OptionData`.
74     :ivar id: Command id, this is received from discord so may not be present
75     """
76 
77     def __init__(
78             self, name, description, options=None, id=None, application_id=None, version=None, **kwargs
79     ):
80         self.name = name
81         self.description = description
82         self.id = id
83         self.application_id = application_id
84         self.version = version
85         if options is not None:
86             self.options = []
87             for option in options:
88                 self.options.append(OptionData(**option))
89         else:
90             self.options = None
91 
92     def __eq__(self, other):
93         if isinstance(other, CommandData):
94             return (
95                     self.name == other.name
96                     and self.description == other.description
97                     and self.options == other.options
98             )
99         else:
100             return False
101 
102 
103 class CommandObject:
104     """
105     Slash command object of this extension.
106 
107     .. warning::
108         Do not manually init this model.
109 
110     :ivar name: Name of the command.
111     :ivar func: The coroutine of the command.
112     :ivar description: Description of the command.
113     :ivar allowed_guild_ids: List of the allowed guild id.
114     :ivar options: List of the option of the command. Used for `auto_register`.
115     :ivar connector: Kwargs connector of the command.
116     :ivar __commands_checks__: Check of the command.
117     """
118 
119     def __init__(self, name, cmd):  # Let's reuse old command formatting.
120         self.name = name.lower()
121         self.func = cmd["func"]
122         self.description = cmd["description"]
123         self.allowed_guild_ids = cmd["guild_ids"] or []
124         self.options = cmd["api_options"] or []
125         self.connector = cmd["connector"] or {}
126         self.has_subcommands = cmd["has_subcommands"]
127         # Ref https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/core.py#L1447
128         # Since this isn't inherited from `discord.ext.commands.Command`, discord.py's check decorator will
129         # add checks at this var.
130         self.__commands_checks__ = []
131         if hasattr(self.func, '__commands_checks__'):
132             self.__commands_checks__ = self.func.__commands_checks__
133 
134     async def invoke(self, *args, **kwargs):
135         """
136         Invokes the command.
137 
138         :param args: Args for the command.
139         :raises: .error.CheckFailure
140         """
141         can_run = await self.can_run(args[0])
142         if not can_run:
143             raise error.CheckFailure
144 
145         return await self.func(*args, **kwargs)
146 
147     def add_check(self, func):
148         """
149         Adds check to the command.
150 
151         :param func: Any callable. Coroutines are supported.
152         """
153         self.__commands_checks__.append(func)
154 
155     def remove_check(self, func):
156         """
157         Removes check to the command.
158 
159         .. note::
160             If the function is not found at the command check, it will ignore.
161 
162         :param func: Any callable. Coroutines are supported.
163         """
164         with suppress(ValueError):
165             self.__commands_checks__.remove(func)
166 
167     async def can_run(self, ctx) -> bool:
168         """
169         Whether the command can be run.
170 
171         :param ctx: SlashContext for the check running.
172         :type ctx: .context.SlashContext
173         :return: bool
174         """
175         res = [bool(x(ctx)) if not iscoroutinefunction(x) else bool(await x(ctx)) for x in self.__commands_checks__]
176         return False not in res
177 
178 
179 class SubcommandObject(CommandObject):
180     """
181     Subcommand object of this extension.
182 
183     .. note::
184         This model inherits :class:`.model.CommandObject`, so this has every variables from that.
185 
186     .. warning::
187         Do not manually init this model.
188 
189     :ivar base: Name of the base slash command.
190     :ivar subcommand_group: Name of the subcommand group. ``None`` if not exist.
191     :ivar base_description: Description of the base command.
192     :ivar subcommand_group_description: Description of the subcommand_group.
193     """
194 
195     def __init__(self, sub, base, name, sub_group=None):
196         sub["has_subcommands"] = True  # For the inherited class.
197         super().__init__(name, sub)
198         self.base = base.lower()
199         self.subcommand_group = sub_group.lower() if sub_group else sub_group
200         self.base_description = sub["base_desc"]
201         self.subcommand_group_description = sub["sub_group_desc"]
202 
203 
204 class CogCommandObject(CommandObject):
205     """
206     Slash command object but for Cog.
207 
208     .. warning::
209         Do not manually init this model.
210     """
211 
212     def __init__(self, *args):
213         super().__init__(*args)
214         self.cog = None  # Manually set this later.
215 
216     async def invoke(self, *args, **kwargs):
217         """
218         Invokes the command.
219 
220         :param args: Args for the command.
221         :raises: .error.CheckFailure
222         """
223         can_run = await self.can_run(args[0])
224         if not can_run:
225             raise error.CheckFailure
226 
227         return await self.func(self.cog, *args, **kwargs)
228 
229 
230 class CogSubcommandObject(SubcommandObject):
231     """
232     Subcommand object but for Cog.
233 
234     .. warning::
235         Do not manually init this model.
236     """
237 
238     def __init__(self, *args):
239         super().__init__(*args)
240         self.cog = None  # Manually set this later.
241 
242     async def invoke(self, *args, **kwargs):
243         """
244         Invokes the command.
245 
246         :param args: Args for the command.
247         :raises: .error.CheckFailure
248         """
249         can_run = await self.can_run(args[0])
250         if not can_run:
251             raise error.CheckFailure
252 
253         return await self.func(self.cog, *args, **kwargs)
254 
255 
256 class SlashCommandOptionType(IntEnum):
257     """
258     Equivalent of `ApplicationCommandOptionType <https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype>`_  in the Discord API.
259     """
260     SUB_COMMAND = 1
261     SUB_COMMAND_GROUP = 2
262     STRING = 3
263     INTEGER = 4
264     BOOLEAN = 5
265     USER = 6
266     CHANNEL = 7
267     ROLE = 8
268 
269     @classmethod
270     def from_type(cls, t: type):
271         """
272         Get a specific SlashCommandOptionType from a type (or object).
273 
274         :param t: The type or object to get a SlashCommandOptionType for.
275         :return: :class:`.model.SlashCommandOptionType` or ``None``
276         """
277         if issubclass(t, str): return cls.STRING
278         if issubclass(t, bool): return cls.BOOLEAN
279         # The check for bool MUST be above the check for integers as booleans subclass integers
280         if issubclass(t, int): return cls.INTEGER
281         if issubclass(t, discord.abc.User): return cls.USER
282         if issubclass(t, discord.abc.GuildChannel): return cls.CHANNEL
283         if issubclass(t, discord.abc.Role): return cls.ROLE
284 
285 
286 class SlashMessage(discord.Message):
287     """discord.py's :class:`discord.Message` but overridden ``edit`` and ``delete`` to work for slash command."""
288 
289     def __init__(self, *, state, channel, data, _http: http.SlashCommandRequest, interaction_token):
290         # Yes I know it isn't the best way but this makes implementation simple.
291         super().__init__(state=state, channel=channel, data=data)
292         self._http = _http
293         self.__interaction_token = interaction_token
294 
295     async def _slash_edit(self, **fields):
296         """
297         An internal function
298         """
299         _resp = {}
300 
301         content = fields.get("content")
302         if content:
303             _resp["content"] = str(content)
304 
305         embed = fields.get("embed")
306         embeds = fields.get("embeds")
307         file = fields.get("file")
308         files = fields.get("files")
309 
310         if embed and embeds:
311             raise error.IncorrectFormat("You can't use both `embed` and `embeds`!")
312         if file and files:
313             raise error.IncorrectFormat("You can't use both `file` and `files`!")
314         if file:
315             files = [file]
316         if embed:
317             embeds = [embed]
318         if embeds:
319             if not isinstance(embeds, list):
320                 raise error.IncorrectFormat("Provide a list of embeds.")
321             elif len(embeds) > 10:
322                 raise error.IncorrectFormat("Do not provide more than 10 embeds.")
323             _resp["embeds"] = [x.to_dict() for x in embeds]
324 
325         allowed_mentions = fields.get("allowed_mentions")
326         _resp["allowed_mentions"] = allowed_mentions.to_dict() if allowed_mentions else \
327             self._state.allowed_mentions.to_dict() if self._state.allowed_mentions else {}
328 
329         await self._http.edit(_resp, self.__interaction_token, self.id, files=files)
330 
331         delete_after = fields.get("delete_after")
332         if delete_after:
333             await self.delete(delay=delete_after)
334         if files:
335             [x.close() for x in files]
336 
337     async def edit(self, **fields):
338         """Refer :meth:`discord.Message.edit`."""
339         if "file" in fields or "files" in fields:
340             await self._slash_edit(**fields)
341         else:
342             try:
343                 await super().edit(**fields)
344             except discord.Forbidden:
345                 await self._slash_edit(**fields)
346 
347     async def delete(self, *, delay=None):
348         """Refer :meth:`discord.Message.delete`."""
349         try:
350             await super().delete(delay=delay)
351         except discord.Forbidden:
352             if not delay:
353                 return await self._http.delete(self.__interaction_token, self.id)
354 
355             async def wrap():
356                 with suppress(discord.HTTPException):
357                     await asyncio.sleep(delay)
358                     await self._http.delete(self.__interaction_token, self.id)
359 
360             self._state.loop.create_task(wrap())
361
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/discord_slash/model.py b/discord_slash/model.py
--- a/discord_slash/model.py
+++ b/discord_slash/model.py
@@ -336,7 +336,7 @@
 
     async def edit(self, **fields):
         """Refer :meth:`discord.Message.edit`."""
-        if "file" in fields or "files" in fields:
+        if "file" in fields or "files" in fields or "embeds" in fields:
             await self._slash_edit(**fields)
         else:
             try:

{"golden_diff": "diff --git a/discord_slash/model.py b/discord_slash/model.py\n--- a/discord_slash/model.py\n+++ b/discord_slash/model.py\n@@ -336,7 +336,7 @@\n \n     async def edit(self, **fields):\n         \"\"\"Refer :meth:`discord.Message.edit`.\"\"\"\n-        if \"file\" in fields or \"files\" in fields:\n+        if \"file\" in fields or \"files\" in fields or \"embeds\" in fields:\n             await self._slash_edit(**fields)\n         else:\n             try:\n", "issue": "Editing SlashMessage should support multiple embeds\nCalling `discord_slash.model.SlashMessage.edit` with an `embeds` kwarg does not work. However the official Discord API documentation says that it should be possible [when editing interaction messages](https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response).\n", "before_files": [{"content": "import asyncio\nimport discord\nfrom enum import IntEnum\nfrom contextlib import suppress\nfrom inspect import iscoroutinefunction\nfrom . import http\nfrom . import error\n\n\nclass ChoiceData:\n    \"\"\"\n    Command choice data object\n\n    :ivar name: Name of the choice, this is what the user will see\n    :ivar value: Values of the choice, this is what discord will return to you\n    \"\"\"\n\n    def __init__(self, name, value):\n        self.name = name\n        self.value = value\n\n    def __eq__(self, other):\n        return isinstance(other, ChoiceData) and self.__dict__ == other.__dict__\n\n\nclass OptionData:\n    \"\"\"\n    Command option data object\n\n    :ivar name: Name of the option.\n    :ivar description: Description of the option.\n    :ivar required: If the option is required.\n    :ivar choices: A list of :class:`ChoiceData`, cannot be present on subcommand groups\n    :ivar options: List of :class:`OptionData`, this will be present if it's a subcommand group\n    \"\"\"\n\n    def __init__(\n            self, name, description, required=False, choices=None, options=None, **kwargs\n    ):\n        self.name = name\n        self.description = description\n        self.type = kwargs.get(\"type\")\n        if self.type is None:\n            raise error.IncorrectCommandData(\"type is required for options\")\n        self.required = required\n        if choices is not None:\n            self.choices = []\n            for choice in choices:\n                self.choices.append(ChoiceData(**choice))\n        else:\n            self.choices = None\n\n        if self.type in (1, 2):\n            self.options = []\n            if options is not None:\n                for option in options:\n                    self.options.append(OptionData(**option))\n            elif self.type == 2:\n                raise error.IncorrectCommandData(\n                    \"Options are required for subcommands / subcommand groups\"\n                )\n\n    def __eq__(self, other):\n        return isinstance(other, OptionData) and self.__dict__ == other.__dict__\n\n\nclass CommandData:\n    \"\"\"\n    Slash command data object\n\n    :ivar name: Name of the command.\n    :ivar description: Description of the command.\n    :ivar options: List of :class:`OptionData`.\n    :ivar id: Command id, this is received from discord so may not be present\n    \"\"\"\n\n    def __init__(\n            self, name, description, options=None, id=None, application_id=None, version=None, **kwargs\n    ):\n        self.name = name\n        self.description = description\n        self.id = id\n        self.application_id = application_id\n        self.version = version\n        if options is not None:\n            self.options = []\n            for option in options:\n                self.options.append(OptionData(**option))\n        else:\n            self.options = None\n\n    def __eq__(self, other):\n        if isinstance(other, CommandData):\n            return (\n                    self.name == other.name\n                    and self.description == other.description\n                    and self.options == other.options\n            )\n        else:\n            return False\n\n\nclass CommandObject:\n    \"\"\"\n    Slash command object of this extension.\n\n    .. warning::\n        Do not manually init this model.\n\n    :ivar name: Name of the command.\n    :ivar func: The coroutine of the command.\n    :ivar description: Description of the command.\n    :ivar allowed_guild_ids: List of the allowed guild id.\n    :ivar options: List of the option of the command. Used for `auto_register`.\n    :ivar connector: Kwargs connector of the command.\n    :ivar __commands_checks__: Check of the command.\n    \"\"\"\n\n    def __init__(self, name, cmd):  # Let's reuse old command formatting.\n        self.name = name.lower()\n        self.func = cmd[\"func\"]\n        self.description = cmd[\"description\"]\n        self.allowed_guild_ids = cmd[\"guild_ids\"] or []\n        self.options = cmd[\"api_options\"] or []\n        self.connector = cmd[\"connector\"] or {}\n        self.has_subcommands = cmd[\"has_subcommands\"]\n        # Ref https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/core.py#L1447\n        # Since this isn't inherited from `discord.ext.commands.Command`, discord.py's check decorator will\n        # add checks at this var.\n        self.__commands_checks__ = []\n        if hasattr(self.func, '__commands_checks__'):\n            self.__commands_checks__ = self.func.__commands_checks__\n\n    async def invoke(self, *args, **kwargs):\n        \"\"\"\n        Invokes the command.\n\n        :param args: Args for the command.\n        :raises: .error.CheckFailure\n        \"\"\"\n        can_run = await self.can_run(args[0])\n        if not can_run:\n            raise error.CheckFailure\n\n        return await self.func(*args, **kwargs)\n\n    def add_check(self, func):\n        \"\"\"\n        Adds check to the command.\n\n        :param func: Any callable. Coroutines are supported.\n        \"\"\"\n        self.__commands_checks__.append(func)\n\n    def remove_check(self, func):\n        \"\"\"\n        Removes check to the command.\n\n        .. note::\n            If the function is not found at the command check, it will ignore.\n\n        :param func: Any callable. Coroutines are supported.\n        \"\"\"\n        with suppress(ValueError):\n            self.__commands_checks__.remove(func)\n\n    async def can_run(self, ctx) -> bool:\n        \"\"\"\n        Whether the command can be run.\n\n        :param ctx: SlashContext for the check running.\n        :type ctx: .context.SlashContext\n        :return: bool\n        \"\"\"\n        res = [bool(x(ctx)) if not iscoroutinefunction(x) else bool(await x(ctx)) for x in self.__commands_checks__]\n        return False not in res\n\n\nclass SubcommandObject(CommandObject):\n    \"\"\"\n    Subcommand object of this extension.\n\n    .. note::\n        This model inherits :class:`.model.CommandObject`, so this has every variables from that.\n\n    .. warning::\n        Do not manually init this model.\n\n    :ivar base: Name of the base slash command.\n    :ivar subcommand_group: Name of the subcommand group. ``None`` if not exist.\n    :ivar base_description: Description of the base command.\n    :ivar subcommand_group_description: Description of the subcommand_group.\n    \"\"\"\n\n    def __init__(self, sub, base, name, sub_group=None):\n        sub[\"has_subcommands\"] = True  # For the inherited class.\n        super().__init__(name, sub)\n        self.base = base.lower()\n        self.subcommand_group = sub_group.lower() if sub_group else sub_group\n        self.base_description = sub[\"base_desc\"]\n        self.subcommand_group_description = sub[\"sub_group_desc\"]\n\n\nclass CogCommandObject(CommandObject):\n    \"\"\"\n    Slash command object but for Cog.\n\n    .. warning::\n        Do not manually init this model.\n    \"\"\"\n\n    def __init__(self, *args):\n        super().__init__(*args)\n        self.cog = None  # Manually set this later.\n\n    async def invoke(self, *args, **kwargs):\n        \"\"\"\n        Invokes the command.\n\n        :param args: Args for the command.\n        :raises: .error.CheckFailure\n        \"\"\"\n        can_run = await self.can_run(args[0])\n        if not can_run:\n            raise error.CheckFailure\n\n        return await self.func(self.cog, *args, **kwargs)\n\n\nclass CogSubcommandObject(SubcommandObject):\n    \"\"\"\n    Subcommand object but for Cog.\n\n    .. warning::\n        Do not manually init this model.\n    \"\"\"\n\n    def __init__(self, *args):\n        super().__init__(*args)\n        self.cog = None  # Manually set this later.\n\n    async def invoke(self, *args, **kwargs):\n        \"\"\"\n        Invokes the command.\n\n        :param args: Args for the command.\n        :raises: .error.CheckFailure\n        \"\"\"\n        can_run = await self.can_run(args[0])\n        if not can_run:\n            raise error.CheckFailure\n\n        return await self.func(self.cog, *args, **kwargs)\n\n\nclass SlashCommandOptionType(IntEnum):\n    \"\"\"\n    Equivalent of `ApplicationCommandOptionType <https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype>`_  in the Discord API.\n    \"\"\"\n    SUB_COMMAND = 1\n    SUB_COMMAND_GROUP = 2\n    STRING = 3\n    INTEGER = 4\n    BOOLEAN = 5\n    USER = 6\n    CHANNEL = 7\n    ROLE = 8\n\n    @classmethod\n    def from_type(cls, t: type):\n        \"\"\"\n        Get a specific SlashCommandOptionType from a type (or object).\n\n        :param t: The type or object to get a SlashCommandOptionType for.\n        :return: :class:`.model.SlashCommandOptionType` or ``None``\n        \"\"\"\n        if issubclass(t, str): return cls.STRING\n        if issubclass(t, bool): return cls.BOOLEAN\n        # The check for bool MUST be above the check for integers as booleans subclass integers\n        if issubclass(t, int): return cls.INTEGER\n        if issubclass(t, discord.abc.User): return cls.USER\n        if issubclass(t, discord.abc.GuildChannel): return cls.CHANNEL\n        if issubclass(t, discord.abc.Role): return cls.ROLE\n\n\nclass SlashMessage(discord.Message):\n    \"\"\"discord.py's :class:`discord.Message` but overridden ``edit`` and ``delete`` to work for slash command.\"\"\"\n\n    def __init__(self, *, state, channel, data, _http: http.SlashCommandRequest, interaction_token):\n        # Yes I know it isn't the best way but this makes implementation simple.\n        super().__init__(state=state, channel=channel, data=data)\n        self._http = _http\n        self.__interaction_token = interaction_token\n\n    async def _slash_edit(self, **fields):\n        \"\"\"\n        An internal function\n        \"\"\"\n        _resp = {}\n\n        content = fields.get(\"content\")\n        if content:\n            _resp[\"content\"] = str(content)\n\n        embed = fields.get(\"embed\")\n        embeds = fields.get(\"embeds\")\n        file = fields.get(\"file\")\n        files = fields.get(\"files\")\n\n        if embed and embeds:\n            raise error.IncorrectFormat(\"You can't use both `embed` and `embeds`!\")\n        if file and files:\n            raise error.IncorrectFormat(\"You can't use both `file` and `files`!\")\n        if file:\n            files = [file]\n        if embed:\n            embeds = [embed]\n        if embeds:\n            if not isinstance(embeds, list):\n                raise error.IncorrectFormat(\"Provide a list of embeds.\")\n            elif len(embeds) > 10:\n                raise error.IncorrectFormat(\"Do not provide more than 10 embeds.\")\n            _resp[\"embeds\"] = [x.to_dict() for x in embeds]\n\n        allowed_mentions = fields.get(\"allowed_mentions\")\n        _resp[\"allowed_mentions\"] = allowed_mentions.to_dict() if allowed_mentions else \\\n            self._state.allowed_mentions.to_dict() if self._state.allowed_mentions else {}\n\n        await self._http.edit(_resp, self.__interaction_token, self.id, files=files)\n\n        delete_after = fields.get(\"delete_after\")\n        if delete_after:\n            await self.delete(delay=delete_after)\n        if files:\n            [x.close() for x in files]\n\n    async def edit(self, **fields):\n        \"\"\"Refer :meth:`discord.Message.edit`.\"\"\"\n        if \"file\" in fields or \"files\" in fields:\n            await self._slash_edit(**fields)\n        else:\n            try:\n                await super().edit(**fields)\n            except discord.Forbidden:\n                await self._slash_edit(**fields)\n\n    async def delete(self, *, delay=None):\n        \"\"\"Refer :meth:`discord.Message.delete`.\"\"\"\n        try:\n            await super().delete(delay=delay)\n        except discord.Forbidden:\n            if not delay:\n                return await self._http.delete(self.__interaction_token, self.id)\n\n            async def wrap():\n                with suppress(discord.HTTPException):\n                    await asyncio.sleep(delay)\n                    await self._http.delete(self.__interaction_token, self.id)\n\n            self._state.loop.create_task(wrap())\n", "path": "discord_slash/model.py"}], "after_files": [{"content": "import asyncio\nimport discord\nfrom enum import IntEnum\nfrom contextlib import suppress\nfrom inspect import iscoroutinefunction\nfrom . import http\nfrom . import error\n\n\nclass ChoiceData:\n    \"\"\"\n    Command choice data object\n\n    :ivar name: Name of the choice, this is what the user will see\n    :ivar value: Values of the choice, this is what discord will return to you\n    \"\"\"\n\n    def __init__(self, name, value):\n        self.name = name\n        self.value = value\n\n    def __eq__(self, other):\n        return isinstance(other, ChoiceData) and self.__dict__ == other.__dict__\n\n\nclass OptionData:\n    \"\"\"\n    Command option data object\n\n    :ivar name: Name of the option.\n    :ivar description: Description of the option.\n    :ivar required: If the option is required.\n    :ivar choices: A list of :class:`ChoiceData`, cannot be present on subcommand groups\n    :ivar options: List of :class:`OptionData`, this will be present if it's a subcommand group\n    \"\"\"\n\n    def __init__(\n            self, name, description, required=False, choices=None, options=None, **kwargs\n    ):\n        self.name = name\n        self.description = description\n        self.type = kwargs.get(\"type\")\n        if self.type is None:\n            raise error.IncorrectCommandData(\"type is required for options\")\n        self.required = required\n        if choices is not None:\n            self.choices = []\n            for choice in choices:\n                self.choices.append(ChoiceData(**choice))\n        else:\n            self.choices = None\n\n        if self.type in (1, 2):\n            self.options = []\n            if options is not None:\n                for option in options:\n                    self.options.append(OptionData(**option))\n            elif self.type == 2:\n                raise error.IncorrectCommandData(\n                    \"Options are required for subcommands / subcommand groups\"\n                )\n\n    def __eq__(self, other):\n        return isinstance(other, OptionData) and self.__dict__ == other.__dict__\n\n\nclass CommandData:\n    \"\"\"\n    Slash command data object\n\n    :ivar name: Name of the command.\n    :ivar description: Description of the command.\n    :ivar options: List of :class:`OptionData`.\n    :ivar id: Command id, this is received from discord so may not be present\n    \"\"\"\n\n    def __init__(\n            self, name, description, options=None, id=None, application_id=None, version=None, **kwargs\n    ):\n        self.name = name\n        self.description = description\n        self.id = id\n        self.application_id = application_id\n        self.version = version\n        if options is not None:\n            self.options = []\n            for option in options:\n                self.options.append(OptionData(**option))\n        else:\n            self.options = None\n\n    def __eq__(self, other):\n        if isinstance(other, CommandData):\n            return (\n                    self.name == other.name\n                    and self.description == other.description\n                    and self.options == other.options\n            )\n        else:\n            return False\n\n\nclass CommandObject:\n    \"\"\"\n    Slash command object of this extension.\n\n    .. warning::\n        Do not manually init this model.\n\n    :ivar name: Name of the command.\n    :ivar func: The coroutine of the command.\n    :ivar description: Description of the command.\n    :ivar allowed_guild_ids: List of the allowed guild id.\n    :ivar options: List of the option of the command. Used for `auto_register`.\n    :ivar connector: Kwargs connector of the command.\n    :ivar __commands_checks__: Check of the command.\n    \"\"\"\n\n    def __init__(self, name, cmd):  # Let's reuse old command formatting.\n        self.name = name.lower()\n        self.func = cmd[\"func\"]\n        self.description = cmd[\"description\"]\n        self.allowed_guild_ids = cmd[\"guild_ids\"] or []\n        self.options = cmd[\"api_options\"] or []\n        self.connector = cmd[\"connector\"] or {}\n        self.has_subcommands = cmd[\"has_subcommands\"]\n        # Ref https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/core.py#L1447\n        # Since this isn't inherited from `discord.ext.commands.Command`, discord.py's check decorator will\n        # add checks at this var.\n        self.__commands_checks__ = []\n        if hasattr(self.func, '__commands_checks__'):\n            self.__commands_checks__ = self.func.__commands_checks__\n\n    async def invoke(self, *args, **kwargs):\n        \"\"\"\n        Invokes the command.\n\n        :param args: Args for the command.\n        :raises: .error.CheckFailure\n        \"\"\"\n        can_run = await self.can_run(args[0])\n        if not can_run:\n            raise error.CheckFailure\n\n        return await self.func(*args, **kwargs)\n\n    def add_check(self, func):\n        \"\"\"\n        Adds check to the command.\n\n        :param func: Any callable. Coroutines are supported.\n        \"\"\"\n        self.__commands_checks__.append(func)\n\n    def remove_check(self, func):\n        \"\"\"\n        Removes check to the command.\n\n        .. note::\n            If the function is not found at the command check, it will ignore.\n\n        :param func: Any callable. Coroutines are supported.\n        \"\"\"\n        with suppress(ValueError):\n            self.__commands_checks__.remove(func)\n\n    async def can_run(self, ctx) -> bool:\n        \"\"\"\n        Whether the command can be run.\n\n        :param ctx: SlashContext for the check running.\n        :type ctx: .context.SlashContext\n        :return: bool\n        \"\"\"\n        res = [bool(x(ctx)) if not iscoroutinefunction(x) else bool(await x(ctx)) for x in self.__commands_checks__]\n        return False not in res\n\n\nclass SubcommandObject(CommandObject):\n    \"\"\"\n    Subcommand object of this extension.\n\n    .. note::\n        This model inherits :class:`.model.CommandObject`, so this has every variables from that.\n\n    .. warning::\n        Do not manually init this model.\n\n    :ivar base: Name of the base slash command.\n    :ivar subcommand_group: Name of the subcommand group. ``None`` if not exist.\n    :ivar base_description: Description of the base command.\n    :ivar subcommand_group_description: Description of the subcommand_group.\n    \"\"\"\n\n    def __init__(self, sub, base, name, sub_group=None):\n        sub[\"has_subcommands\"] = True  # For the inherited class.\n        super().__init__(name, sub)\n        self.base = base.lower()\n        self.subcommand_group = sub_group.lower() if sub_group else sub_group\n        self.base_description = sub[\"base_desc\"]\n        self.subcommand_group_description = sub[\"sub_group_desc\"]\n\n\nclass CogCommandObject(CommandObject):\n    \"\"\"\n    Slash command object but for Cog.\n\n    .. warning::\n        Do not manually init this model.\n    \"\"\"\n\n    def __init__(self, *args):\n        super().__init__(*args)\n        self.cog = None  # Manually set this later.\n\n    async def invoke(self, *args, **kwargs):\n        \"\"\"\n        Invokes the command.\n\n        :param args: Args for the command.\n        :raises: .error.CheckFailure\n        \"\"\"\n        can_run = await self.can_run(args[0])\n        if not can_run:\n            raise error.CheckFailure\n\n        return await self.func(self.cog, *args, **kwargs)\n\n\nclass CogSubcommandObject(SubcommandObject):\n    \"\"\"\n    Subcommand object but for Cog.\n\n    .. warning::\n        Do not manually init this model.\n    \"\"\"\n\n    def __init__(self, *args):\n        super().__init__(*args)\n        self.cog = None  # Manually set this later.\n\n    async def invoke(self, *args, **kwargs):\n        \"\"\"\n        Invokes the command.\n\n        :param args: Args for the command.\n        :raises: .error.CheckFailure\n        \"\"\"\n        can_run = await self.can_run(args[0])\n        if not can_run:\n            raise error.CheckFailure\n\n        return await self.func(self.cog, *args, **kwargs)\n\n\nclass SlashCommandOptionType(IntEnum):\n    \"\"\"\n    Equivalent of `ApplicationCommandOptionType <https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype>`_  in the Discord API.\n    \"\"\"\n    SUB_COMMAND = 1\n    SUB_COMMAND_GROUP = 2\n    STRING = 3\n    INTEGER = 4\n    BOOLEAN = 5\n    USER = 6\n    CHANNEL = 7\n    ROLE = 8\n\n    @classmethod\n    def from_type(cls, t: type):\n        \"\"\"\n        Get a specific SlashCommandOptionType from a type (or object).\n\n        :param t: The type or object to get a SlashCommandOptionType for.\n        :return: :class:`.model.SlashCommandOptionType` or ``None``\n        \"\"\"\n        if issubclass(t, str): return cls.STRING\n        if issubclass(t, bool): return cls.BOOLEAN\n        # The check for bool MUST be above the check for integers as booleans subclass integers\n        if issubclass(t, int): return cls.INTEGER\n        if issubclass(t, discord.abc.User): return cls.USER\n        if issubclass(t, discord.abc.GuildChannel): return cls.CHANNEL\n        if issubclass(t, discord.abc.Role): return cls.ROLE\n\n\nclass SlashMessage(discord.Message):\n    \"\"\"discord.py's :class:`discord.Message` but overridden ``edit`` and ``delete`` to work for slash command.\"\"\"\n\n    def __init__(self, *, state, channel, data, _http: http.SlashCommandRequest, interaction_token):\n        # Yes I know it isn't the best way but this makes implementation simple.\n        super().__init__(state=state, channel=channel, data=data)\n        self._http = _http\n        self.__interaction_token = interaction_token\n\n    async def _slash_edit(self, **fields):\n        \"\"\"\n        An internal function\n        \"\"\"\n        _resp = {}\n\n        content = fields.get(\"content\")\n        if content:\n            _resp[\"content\"] = str(content)\n\n        embed = fields.get(\"embed\")\n        embeds = fields.get(\"embeds\")\n        file = fields.get(\"file\")\n        files = fields.get(\"files\")\n\n        if embed and embeds:\n            raise error.IncorrectFormat(\"You can't use both `embed` and `embeds`!\")\n        if file and files:\n            raise error.IncorrectFormat(\"You can't use both `file` and `files`!\")\n        if file:\n            files = [file]\n        if embed:\n            embeds = [embed]\n        if embeds:\n            if not isinstance(embeds, list):\n                raise error.IncorrectFormat(\"Provide a list of embeds.\")\n            elif len(embeds) > 10:\n                raise error.IncorrectFormat(\"Do not provide more than 10 embeds.\")\n            _resp[\"embeds\"] = [x.to_dict() for x in embeds]\n\n        allowed_mentions = fields.get(\"allowed_mentions\")\n        _resp[\"allowed_mentions\"] = allowed_mentions.to_dict() if allowed_mentions else \\\n            self._state.allowed_mentions.to_dict() if self._state.allowed_mentions else {}\n\n        await self._http.edit(_resp, self.__interaction_token, self.id, files=files)\n\n        delete_after = fields.get(\"delete_after\")\n        if delete_after:\n            await self.delete(delay=delete_after)\n        if files:\n            [x.close() for x in files]\n\n    async def edit(self, **fields):\n        \"\"\"Refer :meth:`discord.Message.edit`.\"\"\"\n        if \"file\" in fields or \"files\" in fields or \"embeds\" in fields:\n            await self._slash_edit(**fields)\n        else:\n            try:\n                await super().edit(**fields)\n            except discord.Forbidden:\n                await self._slash_edit(**fields)\n\n    async def delete(self, *, delay=None):\n        \"\"\"Refer :meth:`discord.Message.delete`.\"\"\"\n        try:\n            await super().delete(delay=delay)\n        except discord.Forbidden:\n            if not delay:\n                return await self._http.delete(self.__interaction_token, self.id)\n\n            async def wrap():\n                with suppress(discord.HTTPException):\n                    await asyncio.sleep(delay)\n                    await self._http.delete(self.__interaction_token, self.id)\n\n            self._state.loop.create_task(wrap())\n", "path": "discord_slash/model.py"}]}