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

166
Visualizações
I can't understand why my message doesn't send to every user that decided to be notified. It only sends to one

I can't understand why my message doesn't send to every user that decided to be notified. It only sends to one. If there are any documents about quick.db to fix it of course let me know.


Here's the notify.js code


module.exports = {
  name: 'notify',
  description: 'Notify people when a new update is released',
  category: "Notified",
  execute(client, message, args, Discord) {
    if(message.member.user.id === '601364286731714591'){
      const db = require('quick.db')
      let notification = db.get(`notifiedusers_${message.author.id}`);
      if(notification === null) {
        return message.channel.send('Nobody is notified for any updates')
      }
      const content = args.join(" ")
      if(!content) return message.channel.send('What would be the content of the Update Be ?')
      
      const newEmbed = new Discord.MessageEmbed()
        .setColor('#b5b5b5')
        .setTitle('Update')
        .setDescription(`${content}`)
      message.channel.send('Notifying everybody that desiced to be notified')
      try{
      const chx = client.users.cache.get(notification)
      chx.send({embeds: [newEmbed]})
      }finally{
        message.channel.send('Everybody was notified')
      }
    }else{
      return
    }
  }
}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

      const chx = client.users.cache.get(notification)
      chx.send({embeds: [newEmbed]})

In this function you can only use 1 id to get the user object of the person, if you have an array of people's ids which you can store using db.push you can then get every person's id and send it to each person

      for (const id of <array_of_id>){
         const chx = client.users.cache.get(id)
         chx.send({embeds: [newEmbed]})
      }

Also, doing too many requests to discord's API will get you ratelimited so give a time to send to each user

      for(const id of <array_of_id>){
         const chx = client.users.cache.get(id)
         chx.send({embeds: [newEmbed]})
         // Wait 3000 milliseconds (3 minutes)
         await new Promise(r => setTimeout(r, 3000));
      }
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