I get this error:
Client.on("guildCreate", (guild) => {
TypeError: Client.on is not a function
My code is:
const client = require("../index");
const { MessageEmbed } = require("discord.js");
client.on("guildCreate", (guild) => {
let channelToSend;
guild.channels.cache.forEach((channel) => {
if (
channel.type === "text" &&
!channelToSend &&
channel.permissionsFor(guild.me).has("SEND_MESSAGES")
) channelToSend = channel;
});
if(!channelToSend) return;
channelToSend.send(
new MessageEmbed()
.setAuthor(guild.name, guild.iconURL({ dynamic: true }))
.setDescription("Thanks for inviting me my prefix is '?'")
.setColor("RANDOM")
.setTimestamp()
)
});
You are not creating the client correctly.
The official documentation said to do that for creating the client:
const { Client } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });