Python / Discord-我正在制作一个不和谐的机器人,但是os模块有一些问题:

时间:2020-08-19 20:59:50

标签: python discord discord.py

这是我的代码,添加后导致错误:

如果message.content ==“ ID开始”:

        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")

这是错误消息:

忽略on_message中的异常 追溯(最近一次通话): _run_event中的文件“ C:\ Users \ User \ AppData \ Local \ Programs \ Python \ Python38 \ lib \ site-packages \ discord \ client.py”,第312行 等待科罗(* args,** kwargs) on_message中的文件“ C:/Users/User/Desktop/idlerpgtest.py”,第31行 路径= os.path.join(目录,文件) 连接中的文件“ C:\ Users \ User \ AppData \ Local \ Programs \ Python \ Python38 \ lib \ ntpath.py”,行117 genericpath._check_arg_types('join',path,* paths) 文件“ C:\ Users \ User \ AppData \ Local \ Programs \ Python \ Python38 \ lib \ genericpath.py”,第152行,_check_arg_types 引发TypeError(f'{funcname}()参数必须为str,字节或' TypeError:join()参数必须是str,bytes或os.PathLike对象,而不是'Member'

似乎这些错误中的大多数与模块或其他文件有关,我只是无法找出解决方法。

1 个答案:

答案 0 :(得分:1)

try str(message.author)看起来像是您试图将两件事结合在一起,其中之一不是字符串。