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

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 (:
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);
}