【问题标题】:When running bot sample code, I get this error运行机器人示例代码时,我收到此错误
【发布时间】:2018-05-11 08:14:20
【问题描述】:

我的代码正是

This (当然是我的令牌)

当我运行它时,我的机器人正常启动,但是当一个新人添加到服务器时,我得到了这个。

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

(对不起,它不在代码块中,我是堆栈交换的新手)

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

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

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

    【讨论】:

    • 谢谢,我越来越近了。但是,当我运行它并且用户加入时,机器人崩溃并出现错误 TypeError: 'module' object is not callable 我用 discord.Object('Mychannelid') 替换了变量 Server 被调用的所有地方
    • 你只想改变这个服务器,await client.send_message(server) ... 用 discord.Object('id') 替换那个服务器。
    • 谢谢。我是 discord.py 的新手,非常感谢您的帮助。 Bot 已启动并正在运行,或者至少是其中的一部分。再次感谢!
    猜你喜欢
    • 2020-10-03
    • 2021-12-14
    • 2022-07-15
    • 2022-06-13
    • 2020-05-10
    • 1970-01-01
    • 2018-12-09
    • 2023-03-23
    • 1970-01-01
    相关资源
    最近更新 更多