No puedo entender por qué mi mensaje no se envía a todos los usuarios que decidieron recibir una notificación. Solo se envía a uno. Si hay algún documento sobre quick.db para arreglarlo, por supuesto, házmelo saber.
Aquí está el código de notificar.js
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 } } }
const chx = client.users.cache.get(notification) chx.send({embeds: [newEmbed]})
En esta función, solo puede usar 1 identificación para obtener el objeto de usuario de la persona, si tiene una matriz de identificaciones de personas que puede almacenar usando db.push
, puede obtener la identificación de cada persona y enviársela a cada persona
for (const id of <array_of_id>){ const chx = client.users.cache.get(id) chx.send({embeds: [newEmbed]}) }
Además, hacer demasiadas solicitudes a la API de ratelimited
hará que tenga una tasa limitada, así que dé un tiempo para send
a cada usuario
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)); }