0
votes

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

1

1 Answers

2
votes

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"]})