Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda