Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
How do I make my discord bot to send a message on a certain time or date

Let's say I wanted my bot to greet me at my birthday and have my bot greet me in a direct message every single year. How can we achieve it ?

Code :

const { Client, MessageEmbed, Intents } = require('discord.js');

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

const d = new Date();
const minutes = d.getMinutes();

client.once('ready', () => {
    console.log('beep boop thirdy is online');
    }
)

client.on('messageCreate', message => {

    
    if(message.content === '!dm')
    client.users.fetch('471298666586570762', false).then((user) => {
        
            user.send("test")
              
      
        });
        

})

client.login('token');

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This can be achieved by an answer in this post, You can use a similar method but you will need to account for a possible leap year every 4 years You also need to update the datestr1 each year after a check and save it in a database

const datestr1 = "7/13/2015"
const datestr2 = "7/13/2016"
const date1 = new Date(datestr1);
const date2 = new Date(datestr2);
const diffTime = Math.abs(date2 - date1);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
const currdateyear = parseInt(datestr2.substring(datestr2.length - 4))
if (currdateyear % 4 === 0) {
  if (diffDays === 366) console.log("happy bday")
} else if (diffDays === 365) console.log("happy bday")

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!