# Buggy code
def send(
    self,
    content=None,
    *,
    wait=False,
    username=None,
    avatar_url=None,
    tts=False,
    file=None,
    files=None,
    embed=None,
    embeds=None,
):
    """|maybecoro|

    Sends a message using the webhook.

    If the webhook is constructed with a :class:`RequestsWebhookAdapter` then this is
    not a coroutine.

    The content must be a type that can convert to a string through ``str(content)``.

    To upload a single file, the ``file`` parameter should be used with a
    single :class:`File` object.

    If the ``embed`` parameter is provided, it must be of type :class:`Embed` and
    it must be a rich embed type. You cannot mix the ``embed`` parameter with the
    ``embeds`` parameter, which must be a :class:`list` of :class:`Embed` objects to send.

    Parameters
    ------------
    content
        The content of the message to send.
    wait: bool
        Whether the server should wait before sending a response. This essentially
        means that the return type of this function changes from ``None`` to
        a :class:`Message` if set to ``True``.
    username: str
        The username to send with this message. If no username is provided
        then the default username for the webhook is used.
    avatar_url: str
        The avatar URL to send with this message. If no avatar URL is provided
        then the default avatar for the webhook is used.
    tts: bool
        Indicates if the message should be sent using text-to-speech.
    file: :class:`File`
        The file to upload. This cannot be mixed with ``files`` parameter.
    files: List[:class:`File`]
        A list of files to send with the content. This cannot be mixed with the
        ``file`` parameter.
    embed: :class:`Embed`
        The rich embed for the content to send. This cannot be mixed with
        ``embeds`` parameter.
    embeds: List[:class:`Embed`]
        A list of embeds to send with the content. Maximum of 10. This cannot
        be mixed with the ``embed`` parameter.

    Raises
    --------
    HTTPException
        Sending the message failed.
    NotFound
        This webhook was not found.
    Forbidden
        The authorization token for the webhook is incorrect.
    InvalidArgument
        You specified both ``embed`` and ``embeds`` or the length of
        ``embeds`` was invalid.

    Returns
    ---------
    Optional[:class:`Message`]
        The message that was sent.
    """

    payload = {}

    if files is not None and file is not None:
        raise InvalidArgument("Cannot mix file and files keyword arguments.")
    if embeds is not None and embed is not None:
        raise InvalidArgument("Cannot mix embed and embeds keyword arguments.")

    if embeds is not None:
        if len(embeds) > 10:
            raise InvalidArgument("embeds has a maximum of 10 elements.")
        payload["embeds"] = [e.to_dict() for e in embeds]

    if embed is not None:
        payload["embeds"] = [embed.to_dict()]

    if content is not None:
        payload["content"] = str(content)

    payload["tts"] = tts
    if avatar_url:
        payload["avatar_url"] = avatar_url
    if username:
        payload["username"] = username

    if file is not None:
        try:
            to_pass = (file.filename, file.open_file(), "application/octet-stream")
            return self._adapter.execute_webhook(
                wait=wait, file=to_pass, payload=payload
            )
        finally:
            file.close()
    elif files is not None:
        try:
            to_pass = [
                (file.filename, file.open_file(), "application/octet-stream")
                for file in files
            ]
            return self._adapter.execute_webhook(
                wait=wait, files=to_pass, payload=payload
            )
        finally:
            for file in files:
                file.close()
    else:
        return self._adapter.execute_webhook(wait=wait, payload=payload)


# Traceback (ValueError)
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 62, in wrapped
ret = await coro(*args, **kwargs)
File "/home/fedora/Thanatos/modules/test.py", line 9, in test
await webhook.send(file=discord.File("file.txt"))
File "/usr/local/lib/python3.7/site-packages/discord/webhook.py", line 194, in handle_execution_response
data = await response
File "/usr/local/lib/python3.7/site-packages/discord/webhook.py", line 162, in request
async with self.session.request(verb, url, headers=headers, data=data) as r:
File "/usr/local/lib64/python3.7/site-packages/aiohttp/client.py", line 855, in __aenter__
self._resp = await self._coro
File "/usr/local/lib64/python3.7/site-packages/aiohttp/client.py", line 361, in _request
ssl=ssl, proxy_headers=proxy_headers, traces=traces)
File "/usr/local/lib64/python3.7/site-packages/aiohttp/client_reqrep.py", line 233, in __init__
self.update_body_from_data(data)
File "/usr/local/lib64/python3.7/site-packages/aiohttp/client_reqrep.py", line 405, in update_body_from_data
body = body()
File "/usr/local/lib64/python3.7/site-packages/aiohttp/formdata.py", line 141, in __call__
return self._gen_form_data()
File "/usr/local/lib64/python3.7/site-packages/aiohttp/formdata.py", line 135, in _gen_form_data
self._writer.append_payload(part)
File "/usr/local/lib64/python3.7/site-packages/aiohttp/multipart.py", line 745, in append_payload
size = payload.size
File "/usr/local/lib64/python3.7/site-packages/aiohttp/payload.py", line 284, in size
return os.fstat(self._value.fileno()).st_size - self._value.tell()
ValueError: I/O operation on closed file

# Fixed code
def send(
    self,
    content=None,
    *,
    wait=False,
    username=None,
    avatar_url=None,
    tts=False,
    file=None,
    files=None,
    embed=None,
    embeds=None,
):
    """|maybecoro|

    Sends a message using the webhook.

    If the webhook is constructed with a :class:`RequestsWebhookAdapter` then this is
    not a coroutine.

    The content must be a type that can convert to a string through ``str(content)``.

    To upload a single file, the ``file`` parameter should be used with a
    single :class:`File` object.

    If the ``embed`` parameter is provided, it must be of type :class:`Embed` and
    it must be a rich embed type. You cannot mix the ``embed`` parameter with the
    ``embeds`` parameter, which must be a :class:`list` of :class:`Embed` objects to send.

    Parameters
    ------------
    content
        The content of the message to send.
    wait: bool
        Whether the server should wait before sending a response. This essentially
        means that the return type of this function changes from ``None`` to
        a :class:`Message` if set to ``True``.
    username: str
        The username to send with this message. If no username is provided
        then the default username for the webhook is used.
    avatar_url: str
        The avatar URL to send with this message. If no avatar URL is provided
        then the default avatar for the webhook is used.
    tts: bool
        Indicates if the message should be sent using text-to-speech.
    file: :class:`File`
        The file to upload. This cannot be mixed with ``files`` parameter.
    files: List[:class:`File`]
        A list of files to send with the content. This cannot be mixed with the
        ``file`` parameter.
    embed: :class:`Embed`
        The rich embed for the content to send. This cannot be mixed with
        ``embeds`` parameter.
    embeds: List[:class:`Embed`]
        A list of embeds to send with the content. Maximum of 10. This cannot
        be mixed with the ``embed`` parameter.

    Raises
    --------
    HTTPException
        Sending the message failed.
    NotFound
        This webhook was not found.
    Forbidden
        The authorization token for the webhook is incorrect.
    InvalidArgument
        You specified both ``embed`` and ``embeds`` or the length of
        ``embeds`` was invalid.

    Returns
    ---------
    Optional[:class:`Message`]
        The message that was sent.
    """

    payload = {}

    if files is not None and file is not None:
        raise InvalidArgument("Cannot mix file and files keyword arguments.")
    if embeds is not None and embed is not None:
        raise InvalidArgument("Cannot mix embed and embeds keyword arguments.")

    if embeds is not None:
        if len(embeds) > 10:
            raise InvalidArgument("embeds has a maximum of 10 elements.")
        payload["embeds"] = [e.to_dict() for e in embeds]

    if embed is not None:
        payload["embeds"] = [embed.to_dict()]

    if content is not None:
        payload["content"] = str(content)

    payload["tts"] = tts
    if avatar_url:
        payload["avatar_url"] = avatar_url
    if username:
        payload["username"] = username

    return self._adapter.execute_webhook(
        wait=wait, file=file, files=files, payload=payload
    )