简体   繁体   English

(Discord.js v13) 无法从频道获取消息

[英](Discord.js v13) Unable to fetch messages from channel

Node.js: v16.13.0 | Node.js:v16.13.0 | Discord.js: v13.3.1 Discord.js:v13.3.1

Hello, I've been getting trying to fetch all the messages from a channel.您好,我一直在尝试从一个频道中获取所有消息。 However, I get the following errors:但是,我收到以下错误:

TypeError: Cannot read properties of undefined (reading 'cache')
TypeError: Cannot read properties of undefined (reading 'fetch')

My code goes like this:我的代码是这样的:

    if(message.content == "!q test")
{
    const channelS = client.channels.cache.get('880814576692789258')

    channelS.messages.fetch().then(messages => { //<---error here
        messages.forEach(msg => console.log(msg.content));
      });
}

What should I do to fix this problem?我应该怎么做才能解决这个问题?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM