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

121
Views
Mi bot enviando múltiples mensajes, discord.js

Para explicarlo brevemente, el código es hacer que los botones ya existentes después de reiniciar el bot se vuelvan a utilizar, guardo para esto el channelId y el messageId. Sin embargo, se almacenan varios mensajes, por lo tanto, foreach(), siempre que solo se almacene un mensaje, todo está bien cuando intento usar un botón, pero si hay 2 o más mensajes, el mensaje se envía con más frecuencia, ¿Cómo puedo solucionar esto?

Espero que alguien pueda ayudarme <3

 fs.readdir(folder, (err, files) => { files.forEach(file => { const r = fs.readFileSync(`${folder}/${file}`, { encoding: "utf-8" }) const data = JSON.parse(r) const channel = client.channels.cache.get(data.channelId) channel.messages.fetch(data.messageId).then(async (message) => { const collector = message.channel.createMessageComponentCollector(); collector.on('collect', async i => { if (i.customId === 'upvote') { return i.channel.send({ content: 'A button was clicked!', components: [] }); } else if (i.customId === 'downvote') { return i.channel.send({ content: 'A button was clicked!', components: [] }); } }); }) }) })
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Está ejecutando su token varias veces. Intente reset your token y ejecútelo en una plataforma.

about 4 years ago · Juan Pablo Isaza Report

0

Supongo que es porque tiene el código ejecutándose dentro de forEach , por lo que posiblemente tenga algún tipo de matriz fuera de él y envíe los mensajes a la matriz, y luego intente enviar el canal de mensajes.

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!