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

239
Views
(DiscordJS) Intentando obtener mensajes antes de la identificación del mensaje, pero sigue obteniendo el más reciente

Tengo una serie de mensajes que quiero recuperar para eliminarlos. Si paso 3-5 por ejemplo y tengo 5 mensajes *abcde*

Espero que mi comando ^delmsg 3-5 borre d y c .

Logré obtener el ID (un copo de nieve) de d y traté de pasarlo a before , pero sigue obteniendo mi comando y e en lugar de d y c . No sé qué más puedo hacer con esto. Tal vez estoy haciendo algo mal con las promesas de las que no estoy al tanto.

Código:

 const deleter = (message, range) => { const range1 = range[0]; //indexes are already an array so we get the first index const amnt = parseInt(range[1]) - parseInt(range[0]); //makes the str index ints var msgs, nID; message.channel.messages.fetch({ limit: range1, }).then(a => { msgs = Array.from(a); nID = msgs[range1-1][0]; }).then(message.channel.messages.fetch({ limit: amnt, before: nID, }).then(b => { //message.channel.bulkDelete(b); })); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

.then espera una función no llamada. También debe usar una función de flecha allí, y debería funcionar según lo previsto

 message.channel.messages.fetch({ limit: range1, }).then(a => { msgs = Array.from(a); nID = msgs[range1-1][0]; }).then(() => message.channel.messages.fetch({ //notice it's an arrow function limit: amnt, before: nID, })).then(b => { message.channel.bulkDelete(b); })

También debe tener en cuenta que el corchete adicional al final debe ir después de .then , donde obtiene los 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!