#bytesIO error

1 messages · Page 1 of 1 (latest)

golden yacht
#

hi again, i made a bulk message delete event and what im trying to make it do is whenever messages are deleted in bulk, an embed gets sent to the log embed saying how many messages got deleted, which works fine. but ive been trying to make it add a .txt file of the messages like in the photo with the embed but i keep getting this error

error:

Traceback (most recent call last):
  File "/Users/st1xkz/bobert/bobert/plugins/listeners/logging.py", line 82, in on_bulk_deleted_message
    attachment = hikari.File(file_data.read(), filename="bulk_delete.txt")
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/st1xkz/bobert/venv/lib/python3.12/site-packages/hikari/files.py", line 896, in __init__
    self.path = ensure_path(path)
                ^^^^^^^^^^^^^^^^^
  File "/Users/st1xkz/bobert/venv/lib/python3.12/site-packages/hikari/files.py", line 149, in ensure_path
    return pathlib.Path(pathish)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/pathlib.py", line 1162, in __init__
    super().__init__(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/pathlib.py", line 373, in __init__
    raise TypeError(
TypeError: argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'bytes'

here is the code: https://pastes.dev/cd1Dt1tjZI

grim bramble
#

and then

#

whole answer summed up

#

your method for file is not correct

#

the argument takes A PathLike object, or a string that represents a path. You've passed the bytes instead

#

the method is not supposed to be working that way

golden yacht
#

oh okay i see

#

thank you

grim bramble
#

🫂 welcome

grim bramble
#

tell me if its working

golden yacht
#

will do

golden yacht
#

it works now