Reputation: 5
I want the message to be sent to a specific channel when I give the command. I want the user to encounter an error if the command was not run on a particular channel. I need your help.
if (msg.author.bot) return;
if (msg.content.toLowerCase() === prefix + 'xgif' ) {
number = 100;
imageNumber = Math.floor (Math.random() * (number -1 + 1)) + 1;
client.channels.get(`channelID`).send( {files: ["./images/" + imageNumber + ".gif"]})
}
Error: TypeError: client.channels.get is not a function
Upvotes: 0
Views: 841
Reputation: 5174
Since discord.js v12 you need to use the cache
property to access channels
collection, so you need to replace
client.channels.get(`channelID`).send( {files: ["./images/" + imageNumber + ".gif"]})
with
client.channels.cache.get(`channelID`).send( {files: ["./images/" + imageNumber + ".gif"]})
Upvotes: 2