#Sending video files

1 messages · Page 1 of 1 (latest)

scenic bolt
#

I can't seem to get the video files downloaded from a url to send, I keep getting the error

  File "/Users/danielisaac/Desktop/Meta/meta-discord/interactions.py/interactions/api/http/http_requests/interactions.py", line 149, in post_initial_response
    return await self.request(
  File "/Users/danielisaac/Desktop/Meta/meta-discord/interactions.py/interactions/api/http/http_client.py", line 380, in request
    processed_data = self._process_payload(payload, files)
  File "/Users/danielisaac/Desktop/Meta/meta-discord/interactions.py/interactions/api/http/http_client.py", line 314, in _process_payload
    file_data = models.open_file(file).read()
  File "/Users/danielisaac/Desktop/Meta/meta-discord/interactions.py/interactions/models/discord/file.py", line 77, in open_file
    raise ValueError(f"{file} is not a valid file")
ValueError: <discord.file.File object at 0x11310d9c0> is not a valid file

Here is my code to download the video and send it

async def upload_video_as_attachment(channel, video_url):
    async with aiohttp.ClientSession() as session:
        async with session.get(video_url) as response:
            video_data = await response.read()
            video_filename = "einstein.mp4"  # You can customize the filename if needed
            video_file = discord.File(io.BytesIO(video_data), filename=video_filename)
            await channel.send(file=video_file)
warm umbraBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

copper wolf
#

use interactions.File

scenic bolt
#

Oh, thanks. Got past the error 😄