#guildCreate not firing

15 messages · Page 1 of 1 (latest)

elder acorn
#

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);
    }
}

}

sacred vortexBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • 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!
elder acorn
#

I did client.emit and it did log sometyhing

gusty tendon
#

Do you have the Guilds intent enabled?

elder acorn
#

Yes, my memberadd event works fine as well

gusty tendon
#

Are you adding a bot user, or just authorising application commands?

elder acorn
#

A bot user

leaden charm
#

How are you adding them?

elder acorn
#

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

gusty tendon
#

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

elder acorn
#

I use the bot and app commands

gusty tendon
#

Can't see any reason this wouldn't fire then if you have the intent

elder acorn
#

Yeah I’m not sure