Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

147
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda