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

231
Views
No se puede detectar un error de cuerpo de formulario no válido discord.js

Estoy tratando de hacer un comando para enviar una inserción basada en datos JSON dados, y funciona, más o menos.

Le doy los datos al bot y, si son correctos, los envía al canal, lo cual es perfecto, exactamente lo que necesito que haga. PERO, si alguien intenta poner texto en una sección de enlace, bloqueará el bot. Intenté intentar atrapar pero no se atrapa por alguna razón.

Error: Scheme "(my string that is not a url)" is not supported. Scheme must be one of ('http', 'https').

 try { let json = message.content.split(" ") json.shift() //get rid of the command bit, leaving the JSON let data = json.join(" ") let embedjson = new Discord.MessageEmbed(JSON.parse(data)) message.channel.send({ embeds: [embedjson]}) //this works, unless it meets the problem listed above. } catch (error) { // >:( wont catch it let errorembed = new Discord.MessageEmbed() console.log(error) .setTitle('Error!') .setDescription(`Something went wrong! There are a few possible issues:\n1. You tried to put text in a link option (Like putting 'hello' in the image option, or 'never gonna give you up' in the thumbnail option.)\n2. Something else\nI'll attatch the error below:`) .addField('Error Message', error) message.channel.send({ embeds: [errorembed]}) }

¿Alguna sugerencia sobre cómo puedo detectar el error? Cualquier ayuda es muy apreciada.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que el cliente de Discord.JS tiene un evento de error que podría registrar el error en lugar de bloquear la instancia del nodo.

Ejemplo:

 client.on('error', (err) => { console.log(err) })

Su código aún generará errores, pero su aplicación continuará ejecutándose. No es ideal, pero es una buena solución si no hay otra manera.

También puede usar process.on('error') , lo que le convenga

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!