Discord.js:表示频道中没有包含消息的消息
这是我的密码Discord.js:表示频道中没有包含消息的消息,discord.js,Discord.js,这是我的密码 import Discord from 'discord.js' const bot = new Discord.Client() const channelID = 'the channel's id' bot.login('my token') bot.on('ready', async () => { const channel = (await bot.channels.fetch(channelID)) as Discord.TextChannel /
import Discord from 'discord.js'
const bot = new Discord.Client()
const channelID = 'the channel's id'
bot.login('my token')
bot.on('ready', async () => {
const channel = (await bot.channels.fetch(channelID)) as Discord.TextChannel //im using typescript
console.log(channel.messages.cache.array())
})
由于某种原因,阵列是空的,即使通道中有大量消息。这可能是什么原因?我知道它得到了正确的通道,因为我已经测试过了,它显示了正确的服务器和名称。谢谢。改用
channel.messages.fetch().array()
。您的数组很可能是空的,因为没有缓存消息,您也可以选择通过执行channel.messages.fetch({},true.array()