TypeError: Cannot read property 'send' of undefined
What did i do wrong? I dont see where i should define it. Probably just a dumb thing i forgot. I would appreciate all improvements/suggestions.
module.exports = {
name: 'suggest',
aliases: ['sug', 'suggestion'],
description: 'Suggest something for the Bot',
execute( client, message, args) {
const filter = m => m.author.id === message.author.id;
message.channel.send(Suggest something for the Bot or send "cancel" to cancel the suggestion)
message.channel.awaitMessages(filter, {max: 1,})
.then(async(collected) => {
if (collected.first().content.toLowerCase() == 'cancel') {
message.reply("The suggestion has been cancelled.")
}
else { client.channels.get("702825446248808519").send(collected.first().content)
message.channel.send(Your suggestion has been sent)
}
})
},
catch (err) {
console.log(err)
}
};
message.channel.send(Suggest something for the Bot or send "cancel" to cancel the suggestion)
This won't work , with this code you are trying to send a var that doesn't exist, i guess you are trying to send a text so it should look like this :
message.channel.send('Suggest something for the Bot or send "cancel" to cancel the suggestion')
It's the same here :
message.channel.send(Your suggestion has been sent)
Becomes :
message.channel.send('Your suggestion has been sent')
Also if you are using discord.js v12 change client.channels.get
to client.channels.cache.get
I hope this helps