I shall start this question with, i'm a beginner for discord.js, and please help me!
My whole index.js is:
const Discord = require('discord.js');
const client = new Discord.Client();
const botsettings = require('./botsettings.json')
client.once('ready', () => {
console.log("Ready!");
});
client.on("message", async message =>{
const playminecraftwithus = message.guild.channels.cache.find(channel => channel.name === 'play-minecraft-with-us')
if(playminecraftwithus.content.startsWith("IGN:")) {
return;
} else {
message.delete();
}
});
client.login(botsettings.token);
and the problem is in this block:
client.on("message", async message =>{
const playminecraftwithus = message.guild.channels.cache.find(channel => channel.name === 'play-minecraft-with-us')
if(playminecraftwithus.content.startsWith("IGN:")) {
return;
} else {
message.delete();
}
});
but error message is like:
(node:13811) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'startsWith' of undefined | discord.js
If you need anything else, please tell me!