discord.py - Send messages though console-这个问题已经过时了,所以我将尝试重新提问,因为这里提供的解决方案不起作用
我希望我的discord机器人通过控制台中的输入向特定通道发送消息。我的代码如下:
channel_entry = 614001879831150605
msg_entry = 'test'
@client.event
async def send2():
channel = client.get_channel(channel_entry.get)
await channel.send(msg_entry)
我得到以下错误:
AttributeError: 'NoneType' object has no attribute 'send'
感谢您的帮助
您不需要将其注册为
client.event
,因为您没有对不和谐中发生的事情做出反应,这意味着不需要装饰器我必须说,我很困惑为什么要对
channel_entry.get
中的整数使用get
。只需使用整数本身。这可能是您错误的根源。因为没有将整数传递给client.get_channel
,所以它返回一个None对象,因为没有找到通道documentation工作示例:
还要确保已安装最新版本的discord.py
相关问题 更多 >
编程相关推荐