#file is not saved

1 messages · Page 1 of 1 (latest)

stone kayakBOT
#
Too Many Tags

Please use either the disnake or python tag, but not both. If your question pertains to disnake, please use the disnake tag. If your question is a general python question that does not depend on disnake, please use the python tag.
I've taken a guess based on the contents of your message which your question is actually about.

If you believe this to be in error, please let us know.

empty locust
#

Are you starting the bot from "moderation"

#

There's probably an images folder in bot that they are going to. Or nowhere because you don't have message content intents.

empty locust
#

So you're actually starting the bot from like /moderation/main.py?

#

Ok..

lost pike
#

show what u have in moderation folder

#

where is ims folder?

#

-d attachment.save

mellow bluffBOT
#

await save(fp, *, seek_begin=True, use_cached=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Saves this attachment into a file-like object.
lost pike
#

i didn't pass fp

#

await attachment.save(f'imgs/{attachment.filename}')

lost pike
#

and?

subtle crag
#

Are you saving the file from main.py or inside a cog

subtle crag
#
img
cogs
soon
util
main.py

Inside util

__init__.py
===========
from .functions import *

functions.py
============
import os

def get_img_file(*args):
    functions_directory = os.path.dirname(os.path.abspath(__file__))
    main_directory = os.path.dirname(functions_directory)
    img_directory = os.path.join(main_directory, 'imgs')
    paths = [arg for arg in args]
    paths.insert(0, img_directory)
    return os.path.join(*paths)

Now inside your cog

from util import get_img_file
...
await attachment.save(get_img_file(attachment.filename))