My discord bots keep spamming mensages in the guildJoin event

When some one join the server, i have my bot configured to send mensage in DM and in Logs-channel, and the boot keeps spamming on those 2 channels.

Ok but what’s wrong ? Can you send some code ? Any error ? I don’t have enough elements to help you…

All code is right. This is code.

index.js: (same in my 2 bots)

  client.on("guildMemberAdd", member => {
    let commandFile = require(`./core/guildJoin.js`);
    commandFile.run(client, member);
  });

Now the mensage in bot who sends on DM

const Discord = require("discord.js");
const db = require("quick.db");
const randomInt = require("random-int");

exports.run = (client, member) => {
  const memberg = member.guild;
  if (db.has(`config_${memberg.id}`)) {
    if (db.get(`config_${memberg.id}.jmsgS`) === "on") {
      member.send(db.get(`config_${memberg.id}.jmgs`));
    }

//...

And the mensage in bot who sends on logs channel

exports.run = async (client, member) => {
    const memberg = member.guild;
  if (memberg.id === "680445015423713299") {
    client.channels
      .get("680518921350021224")
      .send("**[ + ]** " + member + " entrou no servidor!!!");
  }
  if (memberg.id === "566601759183863835") {
    client.channels
      .get("590369089470464006")
      .send("**[ + ]** " + member + " entrou no servidor!!!");
  }
console.log(memberg.id)
};

And in other bots that is hosted on glitch, it sends duplicate messages some times

When you say “spamming” you mean it really spams indefinetly or does it send the message multiple times then stops unless someone else is coming to the server ?

It send mutiple times the same message, some times is 2, other is 8 or +12.

Maybe put a console.log inside the guildMemberAdd event , one inside the DM part, and one inside the logs.

1 - If there is an issue with glitch nothing will be printed in the logs, or at least the amount of message printed in the logs will be inferior to the amount of message sent to Discord.

2 - If the guildMemberAdd event is triggered once but the DM part and logs are triggered multiple times, try checking :

  • If you accidentally trigger it twice (e.g. : When you trigger this part of the code in a loop but it should’ve been outside of it)

3 - If guildMemberAdd is triggered multiple times check :

  • If you created a second instance of the bot or not (mostly if Discord.js is required and defined 2 times)