Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.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
Discord.js TypeError:无法读取属性';信息';未定义的_Discord.js - Fatal编程技术网

Discord.js TypeError:无法读取属性';信息';未定义的

Discord.js TypeError:无法读取属性';信息';未定义的,discord.js,Discord.js,我正在尝试获取通道ID数组的消息,这是代码。console.log会记录通道对象,所以我知道它们在那里。但是,在运行此命令时,它返回TypeError“无法读取未定义的属性“messages” 我还尝试捕获错误,但它仍然不会返回任何内容。元素不是有效的频道ID。是的,请确保您的频道ID实际上是正确的。@Lioness100我也尝试了element.ID,但这会产生相同的错误。如何获取有效的频道ID?除了确保频道ID与bot缓存的现有频道相对应之外,没有太多内容。过滤的频道ID的值是多少?

我正在尝试获取通道ID数组的消息,这是代码。
console.log
会记录通道对象,所以我知道它们在那里。但是,在运行此命令时,它返回TypeError“无法读取未定义的属性“messages”


我还尝试捕获错误,但它仍然不会返回任何内容。

元素
不是有效的频道ID。是的,请确保您的频道ID实际上是正确的。@Lioness100我也尝试了element.ID,但这会产生相同的错误。如何获取有效的频道ID?除了确保频道ID与bot缓存的现有频道相对应之外,没有太多内容。过滤的频道ID的值是多少?
   console.log(filtered_channel_ids);
   filtered_channel_ids.forEach((element) => {
    const channel = client.channels.cache.get(element);
    if (channel.messages) {
     channel.messages
      .fetch({limit: 10})
      .then((message) => console.log(message.content));
    }
   });