0
votes

My discord bot is sending a message automatically everyday at 4am . I don't know why . Here is the code :

let embed = new Discord.MessageEmbed()
          .setTitle("Hello")
          .setColor(0x36393f)
          .setDescription(
            `\`\`\`${table(membersLimited, {
              border: getBorderCharacters(`void`),
            })}\`\`\``
          )
          .setTimestamp();
        guild.channels.cache
          .get(guildData.config.channels.announcements)
          .send(embed);

I can't figure out why my bot send this message every day automatically to ALL the server where it is invited in.

Any idea ?

1
Okay it seems the code was initially put inside a cron job (I didn't write the code myself) const job = new cron.CronJob("00 00 13 * * 0", async () => { code was here }) . I just commented the line but it seems the job is still active. How I can cancel it ?John doe

1 Answers

0
votes

This thread is useful, after you define the cronjon, simply do <cron name>.stop();

var cron = require('cron').CronJob;

var j = cron.scheduleJob(unique_name, '*/1 * * * * *',()=>{
    //Do some work
});
// for some condition in some code
let my_job = cron.scheduledJobs[unique_name];
my_job.stop();