Answer the question
In order to leave comments, you need to log in
How to send a message to all server members?
i want to make all the participants of my server receive notifications from my bot about new events i threw in a small piece of code i hope you can help me fix it so that everyone is sent and not just the mentioned user.thank you in advance
const Discord = module.require("discord.js");
module.exports.run = async (bot, msg, args, database) => {
msg.delete();
var client = bot
if (!args.length) {
return msg.channel.send(`Здесь нет аргументов, ${msg.author.tag}!`);
}
let dmm = args.slice(1).join(" ");
let mem = msg.mentions.members.first()
if (!mem) return;
mem.send(dmm)
}
Answer the question
In order to leave comments, you need to log in
bot.users.cache.forEach(user => {
user.send('ваше_сообщение')
})
if(!msg.member.hasPermission("ADMINISTRATOR")) return
let m = msg.content.split(/ +/).slice(1).join(" ")
if(!m || m=="") return msg.reply("Не указано сообщение")
msg.guild.members.cache.map(m=>m.user).forEach(u=>{
u.createDM()
u.send(m)
})
(node:7484) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user
at RequestHandler.execute (C:\Users\Nikolai\Desktop\mood room bot1\node_modules\discord.js\src\rest\RequestHandler.js:170:25 )
at processTicksAndRejections (internal/process/task_queues.js:97:5)
( node:7484 ) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_reje... ). (rejection id: 1)
(node:7484) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I tried to do what you suggested and ended up with this error.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question