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
d.js toolkit
d.js toolkit3mo ago
- 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!
JollyJohn
JollyJohnOP3mo ago
I did client.emit and it did log sometyhing
monbrey
monbrey3mo ago
Do you have the Guilds intent enabled?
JollyJohn
JollyJohnOP3mo ago
Yes, my memberadd event works fine as well
monbrey
monbrey3mo ago
Are you adding a bot user, or just authorising application commands?
JollyJohn
JollyJohnOP3mo ago
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
monbrey
monbrey3mo ago
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 does
JollyJohn
JollyJohnOP3mo ago
I use the bot and app commands
monbrey
monbrey3mo ago
Can't see any reason this wouldn't fire then if you have the intent
JollyJohn
JollyJohnOP3mo ago
Yeah I’m not sure I’ll check the intents again
Want results from more Discord servers?
Add your server