Я получаю несколько ошибок со строками 12 TypeError: Cannot read property 'user' of undefined
и 14 TypeError: Cannot read property 'guilds' of undefined
У меня может быть несколько других ошибок, которых я еще не видел. Я относительно новичок в кодировании и сейчас пытаюсь научиться кодировать ботов Discord. Любая помощь очень ценится. Вот код моего бота Discord:
const { RichEmbed } = require("discord.js");
const randomPuppy = require("random-puppy");
const Discord = require('discord.js');
const client = new Discord.Client();
const token = 'NzIxOTUwNDcyNjcxNTkyNDc5.XucD3Q.iCVFM3f9vNRrSpKpqwMjzYwKarc';
client.on('ready', async client => {
console.log('This bot is online');
client.user.setActivity("Youtube", {type: "Watching"})
client.guilds.cache.forEach((guild) => {
console.log(guild.name)
guild.channels.cache.forEach((channel) => {
console.log(` - ${channel.name} ${channel.type} ${channel.id}`)
})
//general text id: 721950719657115750
})
const jpg = "https://cdn.discordapp.com/attachments/709199176562638849/722646217930178620/OIPK7JS66QT.jpg"
const img = await randomPuppy(jpg);
const embed = new RichEmbed()
.setColor("RANDOM")
.setImage(img)
.setTitle(`From /r/${random}`)
.setURL(`https://reddit.com/r/${random}`);
message.channel.send(embed);
})
client.on('message', msg=>{
if(msg.content === "hello"){
msg.reply('hello')
}
})
client.login(token);```