Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 当运行bot示例代码时,我得到了这个错误_Python_Discord_Discord.py - Fatal编程技术网

Python 当运行bot示例代码时,我得到了这个错误

Python 当运行bot示例代码时,我得到了这个错误,python,discord,discord.py,Python,Discord,Discord.py,我的代码就是 (当然是我的代币) 当我运行它时,我的bot会正常启动,但是当一个新的用户添加到服务器时,我会得到这个消息 ------ Ignoring exception in on_member_join Traceback (most recent call last): File "C:\Users\USRNAME\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 30

我的代码就是

(当然是我的代币)

当我运行它时,我的bot会正常启动,但是当一个新的用户添加到服务器时,我会得到这个消息

------
Ignoring exception in on_member_join
Traceback (most recent call last):
  File "C:\Users\USRNAME\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 307, in _run_event
    yield from getattr(self, event)(*args, **kwargs)
  File "test.py", line 9, in on_member_join
    await client.send_message(server, fmt.format(member, server))
  File "C:\Users\USRNAME\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 1152, in send_message
    data = yield from self.http.send_message(channel_id, content, guild_id=guild_id, tts=tts, embed=embed)
  File "C:\Users\USRNAME\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\http.py", line 198, in request
    raise NotFound(r, data)
discord.errors.NotFound: NOT FOUND (status code: 404): Unknown Channel
(很抱歉,它不在代码块中,我是stack exchange新手)


任何帮助都将不胜感激。谢谢

这将不再有效,因为discord删除了默认频道,所以将其发送到
服务器
将不起作用。如果使用异步,则应将
服务器
替换为
discord.Object('insert channel id')
如果使用重写分支,则应将
discord.Object(insert channel id)
替换为
。注意字符串与int的区别。祝你好运:)

谢谢,我离你越来越近了。但是,当我运行此操作并有用户加入时,bot会崩溃,错误类型为:error:“module”对象不可调用我用discord替换了变量服务器的所有位置。对象('Mychannelid')您只想更改此服务器,
等待客户端。发送消息(服务器)
。。。用discord.Object('id')替换该服务器。谢谢。我对discord.py不熟悉,我真的很感谢你的帮助。Bot已经启动并运行,或者至少是它的这一部分。再次感谢!