guildCreate not firing
const wlSchema = require('../../Schemas/serverwlSchema.js');
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);
}
}
}10 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!I did client.emit and it did log sometyhing
Do you have the
Guilds
intent enabled?Yes, my memberadd event works fine as well
Are you adding a bot user, or just authorising application commands?
A bot user
The bot?
Wait I might’ve misunderstood, I am just adding the Bot to servers and it uses application commands
English isn’t my first language, sorry
There are two different scope you can add to your invite.
applications.commands
only installs the slash commands and does not add the bot as a GuildMember
The bot
scope doesI use the bot and app commands
Can't see any reason this wouldn't fire then if you have the intent
Yeah I’m not sure
I’ll check the intents again