'Python/Discord --I'm making a discord bot but having some problems with the os module:

This is my code which caused errors when added:

if message.content == "ID start":
    dir=(r'C:\\Users\\User\Desktop\User Profiles')
    file = message.author
    path = os.path.join(dir,file)
    isExist = os.path.exists(path)
    if isExist == True:
        await message.channel.send("You already have a profile")

This is the error message:

Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 312, in _run_event
    await coro(*args, **kwargs)
  File "C:/Users/User/Desktop/idlerpgtest.py", line 31, in on_message
    path = os.path.join(dir,file)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\ntpath.py", line 117, in join
    genericpath._check_arg_types('join', path, *paths)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\genericpath.py", line 152, in _check_arg_types
    raise TypeError(f'{funcname}() argument must be str, bytes, or '
TypeError: join() argument must be str, bytes, or os.PathLike object, not 'Member'

It seems that most of these errors are with modules or other files its trying to call I just cant work out how to fix them.



Solution 1:[1]

try str(message.author) looks like you're trying to join 2 things together, one of which isn't a string.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DavimusPrime