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

206
Views
Cómo borrar una imagen en un canal | DJS

Me gustaría poder eliminar una imagen enviada automáticamente. Pero SÓLO las imágenes y no todos los archivos adjuntos.

Actualmente estoy usando message.attachments.size > 0 . Pero sé que elimina todos los apegos; lo que no quiero!

 async execute(message, client) { if (!message.guild || message.author.bot) return; if (message.channel.id === 'CHANNEL-ID' && message.attachments.size > 0) { message.delete() }

Con mi investigación, encontré una publicación que explicaba que era suficiente agregar filtros; message.attachments.find(attachment => attachment.filename.endsWith('png') || attachment.filename.endsWith('jpg') || attachment.filename.endsWith('gif'))

Pero para mí no funciona; me muestra un error, no parece reconocer el .endsWith

versión del nodo: 16.13.2 | versión npm: 8.1.2

Gracias por adelantado ! 👨🏻‍💻

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

No hay una propiedad llamada nombre de filename en un MessageAttachment . En cambio, tiene una propiedad de name que creo que puede usar. Entonces solo necesita reemplazar la propiedad de nombre de filename con attachment.name

about 4 years ago · Santiago Gelvez 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!