@walkmanofficial
я начинающий програмист только учусь

Как сделать отправление сообщения всем участникам сервера?

я хочу сделать чтобы всем учасникам моего сервера присылались оповещения от моего бота о новых ивентах я накидал небольшой участок кода надеюсь вы поможете мне исправить так чтобы всем отправлялось а не только упомянутому пользователю.Заранее спасибо
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)
    }
  • Вопрос задан
  • 115 просмотров
Пригласить эксперта
Ответы на вопрос 3
Alexandre888
@Alexandre888 Куратор тега Боты
Javascript-разработчик
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)
})
Ответ написан
Комментировать
@walkmanofficial Автор вопроса
я начинающий програмист только учусь
(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.
попробовал сделать то что советовали в итоге эта ошибка
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы