daily pastebin goal
19%
SHARE
TWEET

Untitled

PEACESLMAO Jan 19th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. const Discord = require("discord.js");
  3. const fs = require("fs");
  4. const bot = new Discord.Client({disableEveryone: true});
  5. bot.commands = new Discord.Collection();
  6.  
  7.  
  8. bot.on('message', message => {
  9.     const member = message.member;
  10.     const mess = message.content.toLocaleLowerCase();
  11.     const args = message.content.slice(prefix.length).trim().split(/ +/g);
  12.     const command = args.shift().toLowerCase();
  13.    if (message.content.startsWith('.dm')) {
  14.     let dmMessageArray = message.content.split(" ")
  15.     let dmArgs = dmMessageArray.slice(1);
  16.  
  17.     let role = args[0];
  18.     let arguments = dmArgs.slice(1).join(" ");
  19.     if (!arguments) return message.channel.send("No arguments provided!").then(msg => msg.delete(3000));
  20.     if (!role) return message.channel.send("No role provided!").then(msg => msg.delete(3000));
  21.  
  22.     let foundRole = message.guild.roles.find(r => r.name === role);
  23.     if (!foundRole) return message.channel.send("Can't find that role.").then(msg => msg.delete(3000));
  24.  
  25.     message.guild.members.forEach((member) => {
  26.         if (member.roles.has(foundRole)) {
  27.             member.send(arguments).catch(e => console.log(`Failed to DM ${member.user.tag}`));
  28.             console.log(`DMED ${member.user.tag}`)
  29.         }
  30.     });
  31. };
  32.  
  33. });
  34.  
  35. bot.login(config.token);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top