Javascript Discord bot发送消息特定通道错误

Javascript Discord bot发送消息特定通道错误,javascript,node.js,discord,discord.js,Javascript,Node.js,Discord,Discord.js,我希望在发出命令时将消息发送到特定通道。如果命令未在特定通道上运行,我希望用户遇到错误。我需要你的帮助 if(msg.author.bot)返回; if(msg.content.toLowerCase()==前缀+'xgif'){ 数字=100; imageNumber=Math.floor(Math.random()*(number-1+1))+1; client.channels.get(`channelID`).send({files:[“/images/”+imageNumber+“.g

我希望在发出命令时将消息发送到特定通道。如果命令未在特定通道上运行,我希望用户遇到错误。我需要你的帮助

if(msg.author.bot)返回;
if(msg.content.toLowerCase()==前缀+'xgif'){
数字=100;
imageNumber=Math.floor(Math.random()*(number-1+1))+1;
client.channels.get(`channelID`).send({files:[“/images/”+imageNumber+“.gif”]})
}

错误:
TypeError:client.channels.get不是函数

因为discord.js v12需要使用
缓存
属性访问
频道
集合,所以需要替换

client.channels.get(`channelID`).send({files:[“/images/”+imageNumber+“.gif”]})

client.channels.cache.get(`channelID`).send({files:[“/images/”+imageNumber+“.gif”]})

由于discord.js v12,您需要使用
缓存
属性来访问
频道
集合,因此需要替换

client.channels.get(`channelID`).send({files:[“/images/”+imageNumber+“.gif”]})

client.channels.cache.get(`channelID`).send({files:[“/images/”+imageNumber+“.gif”]})