Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.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
Javascript 如何获取通道中的所有消息?_Javascript_Node.js_Discord_Discord.js - Fatal编程技术网

Javascript 如何获取通道中的所有消息?

Javascript 如何获取通道中的所有消息?,javascript,node.js,discord,discord.js,Javascript,Node.js,Discord,Discord.js,我正在尝试获取频道中的所有消息,但得到的错误是无法发送空消息。 var str = bot.channels.cache.get('729038947380101170').messages.fetch({ limit: 10 }); message.channel.send(str); 这个频道肯定有消息。fetch()有什么问题?fetch()没有什么问题,它只是返回一个承诺,所以您需要等待这个承诺 const channel=bot.channels.cache.get('7290389

我正在尝试获取频道中的所有消息,但得到的错误是
无法发送空消息。

var str = bot.channels.cache.get('729038947380101170').messages.fetch({ limit: 10 });
message.channel.send(str);

这个频道肯定有消息。
fetch()
有什么问题?

fetch()没有什么问题,它只是返回一个承诺,所以您需要等待这个承诺

const channel=bot.channels.cache.get('729038947380101170')
const messages=wait channel.messages.fetch({limit:10});
messages.forEach(msg=>message.channel.send(msg.content));

它仍然给出相同的消息“无法发送空消息”@辛特尔