guildCreate not firing
const wlSchema = require('../../Schemas/serverwlSchema.js');
module.exports = {
name: "guildCreate",
async execute(guild, client) {
console.log(
client.channels.cache.get('1287510923657089054').send(
try {
const wlguilds = await wlSchema.find().lean();
const guildids = wlguilds.map(guild => guild.guildId);
client.guilds.cache.forEach(async guild => {
if (!guildids.includes(guild.id)) {
await guild.leave();
}
})
} catch (error) {
console.error(
}
}
}
module.exports = {
name: "guildCreate",
async execute(guild, client) {
console.log(
I have joined a new server: ${guild.name} with the ID of ${guild.id}.)client.channels.cache.get('1287510923657089054').send(
I have joined a new server: ${guild.name} with the ID of ${guild.id}.)try {
const wlguilds = await wlSchema.find().lean();
const guildids = wlguilds.map(guild => guild.guildId);
client.guilds.cache.forEach(async guild => {
if (!guildids.includes(guild.id)) {
await guild.leave();
}
})
} catch (error) {
console.error(
Error leaving guild ${guild.id}:, error);}
}
}
