Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
how to ignore the discord API errors? Discord js V12

so I've asked this question before, so I made the command "dm-role" here's the code

const { Client, Message, MessageEmbed } = require('discord.js');
//const { join } = require('path');

module.exports = {
    name: 'dm-role',
    /** 
     * @param {Client} client 
     * @param {Message} message 
     * @param {String[]} args 
     */
     run: async(client, message, args) => {
    if (!message.member.hasPermission("ADMINISTRATOR")) return message.channel.send("admin only lol")

    if (!args[0]) return message.channel.send("where's the role?")
    const role = message.mentions.roles.first()

    message.guild.roles.cache.get(role.id).members.forEach(member => member.send(args.slice(1).join(" ")))

    if (!role) return message.channel.send("where's the role?")

    const reason = args.slice(1).join(" ")
    if (!reason) return message.channel.send("the message ?");

    try {
      
        await role.send(reason).catch(error => console.log(error))
        return message.channel.send("done");
    } catch {
        return message.channel.send("failed");
    }
}   
}


so the problem is, I got the error like this enter image description here

enter image description here

I don't know why I get errors like that, even though I've used .catch(error => console.log(error)) and this code used to run fine when my server was still 800+ members and now my server and now since my server has 1500+members, I get an error like that.

Is it because bots can't send 1500+ messages?

I hope someone can help me, Thank you (:

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Look into what calls are causing the errors, but if you want to ignore error messages as in not have them show in the console use:

.catch(error => null);

If using try/catch:

try {
   ...
} catch (err) {
   return;
}

It's best to not use both then/catch and try/catch as they are synchronous vs asynchronous respectively. Stick to one throughout your procedures. Whatever executes .catch() will execute catch () {}

try {
   await role.send(reason);
} catch (err) {
   console.error(err);
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda