You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python开发Discord Bot报错:'Message'对象无'channell'属性的解决

问题原因与修复方案

问题原因

终端报错'Message' object has no attribute 'channell'是因为拼写错误:在bot.py的send_message函数里,你把Discord Message对象的channel属性写成了channell(多了一个字母l)。这个错误导致机器人尝试调用不存在的属性,无法发送响应消息,所以用户输入"hello"时看不到机器人回复。

修复方法

修改bot.py中send_message函数的错误代码行:

错误代码:

await message.author.send(response) if is_private else await message.channell.send(response)

修正后的代码:

await message.author.send(response) if is_private else await message.channel.send(response)

仅需把channell改为channel,机器人就能正确定位消息所在频道并发送响应。

内容的提问来源于stack exchange,提问作者Loh Boon How

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 03:35:21