├── .gitignore ├── README.md ├── commands ├── MassDM │ ├── dm.js │ ├── dnddm.js │ ├── embeddm.js │ ├── idledm.js │ ├── offlinedm.js │ └── onlinedm.js └── misc │ └── help.js ├── config.json ├── events ├── message.js └── ready.js ├── index.js ├── package.json ├── utils └── util.js └── whitelist.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MassDM 2 | 3 | 4 | ***NEW UPDATE SOON*** 5 | -------------------------------------------------------------------------------- /commands/MassDM/dm.js: -------------------------------------------------------------------------------- 1 | const whitelist = require("../../whitelist.json") 2 | 3 | module.exports.execute = async (client, message) => { 4 | 5 | if(message.author.id !== whitelist.id && message.author.id !== whitelist.id2) return message.reply("You are not Whitelisted.") 6 | 7 | let timedOut = false 8 | 9 | const { channel, author } = message 10 | 11 | const isFromAuthor = m => m.author.id == author.id 12 | 13 | const options = { 14 | max: 1, 15 | time: 60 * 1000 16 | } 17 | 18 | await channel.send('Message to Send?') 19 | const firstColl = await channel.awaitMessages(isFromAuthor, options) 20 | 21 | if (firstColl.size > 0) { 22 | const title = firstColl.first().content 23 | 24 | message.guild.members.cache.forEach(member => { 25 | if (member.id !== client.user.id && !member.user.bot) member.send(title).catch(() => {}); 26 | }); 27 | 28 | } else timedOut = true 29 | 30 | if (timedOut) 31 | channel.send('Command canceled (timed out)') 32 | 33 | } 34 | 35 | 36 | 37 | module.exports.help = { 38 | name: "dm", 39 | aliases: [], 40 | category: "MassDM", 41 | usage: "", 42 | description: "Put message to adversite" 43 | } -------------------------------------------------------------------------------- /commands/MassDM/dnddm.js: -------------------------------------------------------------------------------- 1 | const whitelist = require("../../whitelist.json") 2 | 3 | module.exports.execute = async (client, message) => { 4 | 5 | if(message.author.id !== whitelist.id && message.author.id !== whitelist.id2) return message.reply("You are not Whitelisted.") 6 | 7 | let timedOut = false 8 | 9 | const { channel, author } = message 10 | 11 | const isFromAuthor = m => m.author.id == author.id 12 | 13 | const options = { 14 | max: 1, 15 | time: 60 * 1000 16 | } 17 | 18 | await channel.send('Message to Send?') 19 | const firstColl = await channel.awaitMessages(isFromAuthor, options) 20 | 21 | if (firstColl.size > 0) { 22 | const title = firstColl.first().content 23 | 24 | message.guild.members.cache.forEach(member => { 25 | if (member.id !== client.user.id && member.presence.status === 'dnd' && !member.user.bot) member.send(title).catch(() => {}); 26 | }); 27 | 28 | } else timedOut = true 29 | 30 | if (timedOut) 31 | channel.send('Command canceled (timed out)') 32 | 33 | } 34 | 35 | 36 | 37 | module.exports.help = { 38 | name: "ddm", 39 | aliases: [], 40 | category: "MassDM", 41 | usage: "", 42 | description: "Put message to adversite only to DnD members" 43 | } -------------------------------------------------------------------------------- /commands/MassDM/embeddm.js: -------------------------------------------------------------------------------- 1 | const Discord = require("discord.js") 2 | const whitelist = require("../../whitelist.json") 3 | module.exports.execute = async (client, message) => { 4 | 5 | if(message.author.id !== whitelist.id && message.author.id !== whitelist.id2) return message.reply("You are not Whitelisted.") 6 | 7 | let timedOut = false 8 | 9 | const { channel, author } = message 10 | 11 | const isFromAuthor = m => m.author.id == author.id 12 | 13 | const options = { 14 | max: 1, 15 | time: 60 * 1000 16 | } 17 | 18 | await channel.send('Message to Send?') 19 | const firstColl = await channel.awaitMessages(isFromAuthor, options) 20 | 21 | if (firstColl.size > 0) { 22 | const title = firstColl.first().content 23 | 24 | const Embed = new Discord.MessageEmbed() 25 | .setAuthor(message.guild.name, message.guild.iconURL()) 26 | .setDescription(title) 27 | .setFooter("© Advanced MassDM") 28 | .setTimestamp() 29 | 30 | message.guild.members.cache.forEach(member => { 31 | if (member.id !== client.user.id && !member.user.bot) member.send(Embed).catch(() => {}); 32 | }); 33 | 34 | } else timedOut = true 35 | 36 | if (timedOut) 37 | channel.send('Command canceled (timed out)') 38 | 39 | } 40 | 41 | 42 | 43 | module.exports.help = { 44 | name: "edm", 45 | aliases: [], 46 | category: "MassDM", 47 | usage: "", 48 | description: "Put message to adversite" 49 | } -------------------------------------------------------------------------------- /commands/MassDM/idledm.js: -------------------------------------------------------------------------------- 1 | const whitelist = require("../../whitelist.json") 2 | 3 | module.exports.execute = async (client, message) => { 4 | 5 | if(message.author.id !== whitelist.id && message.author.id !== whitelist.id2) return message.reply("You are not Whitelisted.") 6 | 7 | let timedOut = false 8 | 9 | const { channel, author } = message 10 | 11 | const isFromAuthor = m => m.author.id == author.id 12 | 13 | const options = { 14 | max: 1, 15 | time: 60 * 1000 16 | } 17 | 18 | await channel.send('Message to Send?') 19 | const firstColl = await channel.awaitMessages(isFromAuthor, options) 20 | 21 | if (firstColl.size > 0) { 22 | const title = firstColl.first().content 23 | 24 | message.guild.members.cache.forEach(member => { 25 | if (member.id !== client.user.id && member.presence.status === 'idle' && !member.user.bot) member.send(title).catch(() => {}); 26 | }); 27 | 28 | } else timedOut = true 29 | 30 | if (timedOut) 31 | channel.send('Command canceled (timed out)') 32 | 33 | } 34 | 35 | 36 | 37 | module.exports.help = { 38 | name: "idm", 39 | aliases: [], 40 | category: "MassDM", 41 | usage: "", 42 | description: "Put message to adversite only to idle members" 43 | } -------------------------------------------------------------------------------- /commands/MassDM/offlinedm.js: -------------------------------------------------------------------------------- 1 | const whitelist = require("../../whitelist.json") 2 | 3 | module.exports.execute = async (client, message) => { 4 | 5 | if(message.author.id !== whitelist.id && message.author.id !== whitelist.id2) return message.reply("You are not Whitelisted.") 6 | 7 | let timedOut = false 8 | 9 | const { channel, author } = message 10 | 11 | const isFromAuthor = m => m.author.id == author.id 12 | 13 | const options = { 14 | max: 1, 15 | time: 60 * 1000 16 | } 17 | 18 | await channel.send('Message to Send?') 19 | const firstColl = await channel.awaitMessages(isFromAuthor, options) 20 | 21 | if (firstColl.size > 0) { 22 | const title = firstColl.first().content 23 | 24 | message.guild.members.cache.forEach(member => { 25 | if (member.id !== client.user.id && member.presence.status === 'offline' && !member.user.bot) member.send(title).catch(() => {}); 26 | }); 27 | 28 | } else timedOut = true 29 | 30 | if (timedOut) 31 | channel.send('Command canceled (timed out)') 32 | 33 | } 34 | 35 | 36 | 37 | module.exports.help = { 38 | name: "ofdm", 39 | aliases: [], 40 | category: "MassDM", 41 | usage: "", 42 | description: "Put message to adversite only to offline members" 43 | } -------------------------------------------------------------------------------- /commands/MassDM/onlinedm.js: -------------------------------------------------------------------------------- 1 | const whitelist = require("../../whitelist.json") 2 | 3 | module.exports.execute = async (client, message) => { 4 | 5 | if(message.author.id !== whitelist.id && message.author.id !== whitelist.id2) return message.reply("You are not Whitelisted.") 6 | 7 | let timedOut = false 8 | 9 | const { channel, author } = message 10 | 11 | const isFromAuthor = m => m.author.id == author.id 12 | 13 | const options = { 14 | max: 1, 15 | time: 60 * 1000 16 | } 17 | 18 | await channel.send('Message to Send?') 19 | const firstColl = await channel.awaitMessages(isFromAuthor, options) 20 | 21 | if (firstColl.size > 0) { 22 | const title = firstColl.first().content 23 | 24 | message.guild.members.cache.forEach(member => { 25 | if (member.id !== client.user.id && member.presence.status === 'online' && !member.user.bot) member.send(title).catch(() => {}); 26 | }); 27 | 28 | } else timedOut = true 29 | 30 | if (timedOut) 31 | channel.send('Command canceled (timed out)') 32 | 33 | } 34 | 35 | 36 | 37 | module.exports.help = { 38 | name: "odm", 39 | aliases: [], 40 | category: "MassDM", 41 | usage: "", 42 | description: "Put message to adversite only to online members" 43 | } -------------------------------------------------------------------------------- /commands/misc/help.js: -------------------------------------------------------------------------------- 1 | const discord = require("discord.js"); 2 | const { config } = require("../../index.js"); 3 | 4 | module.exports.execute = async (client, message, args) => { 5 | 6 | const helpCommand = client.commands.get("help").help; 7 | const embed = new discord.MessageEmbed() 8 | .setThumbnail(client.user.avatarURL(client.user)) 9 | .setFooter(`Requested by ${message.author.tag}`) 10 | .setTimestamp(); 11 | 12 | if (!args[0]) { 13 | 14 | const categories = [...new Set(client.commands.map(command => command.help.category))]; 15 | 16 | embed.setTitle(`${client.user.tag} | Command list`); 17 | embed.setDescription([ 18 | `**Prefix:** \`${config.prefix}\``, 19 | `<> : Required | [] : Optional`, 20 | `Use \`${config.prefix}${helpCommand.name} ${helpCommand.usage}\` to view command help with more detail.` 21 | ].join("\n")); 22 | 23 | let categorisedCommands; 24 | 25 | for (const category of categories) { 26 | categorisedCommands = client.commands.filter(cmd => cmd.help.category == category); 27 | embed.addField(category, categorisedCommands.map(cmd => `\`${cmd.help.name}\``).join(", ")); 28 | } 29 | 30 | message.channel.send(embed); 31 | return; 32 | } 33 | 34 | const command = client.commands.get(args[0]) || client.commands.get(client.aliases.get(args[0])); 35 | if (!command) return this.execute(client, message, []); 36 | 37 | const commandInfo = command.help; 38 | const aliasesPresent = commandInfo.aliases.length > 0; 39 | 40 | embed.setTitle(`${commandInfo.name.toUpperCase()} COMMAND`); 41 | embed.setDescription(commandInfo.description); 42 | embed.addField("Usage", `\`${config.prefix}${commandInfo.name}${commandInfo.usage != "" ? ` ${commandInfo.usage}` : ""}\``); 43 | embed.addField("Aliases", `${aliasesPresent ? commandInfo.aliases.map(alias => `\`${alias}\``).join(", ") : "\`None\`"}`); 44 | 45 | message.channel.send(embed); 46 | 47 | } 48 | 49 | module.exports.help = { 50 | name: "help", 51 | aliases: [], 52 | category: "Miscellaneous", 53 | usage: "[command]", 54 | description: "Need some help with commands because they are too complicated? Look no further! I am here to your aid!" 55 | } -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "prefix": "/", 3 | "color": "#79cfec", 4 | "version": "1.0.1" 5 | } -------------------------------------------------------------------------------- /events/message.js: -------------------------------------------------------------------------------- 1 | const { client, config } = require("../index.js") 2 | 3 | client.on("message", async message => { 4 | 5 | if (message.author.bot) return; 6 | if (message.channel.type === "dm") return; 7 | 8 | let args = message.content.slice(config.prefix.length).trim().split(" "); 9 | let cmd = args.shift().toLowerCase() 10 | let command; 11 | 12 | if (message.content.startsWith(config.prefix)) { 13 | 14 | if (client.commands.has(cmd)) { 15 | command = client.commands.get(cmd); 16 | } else { 17 | command = client.commands.get(client.aliases.get(cmd)); 18 | } 19 | 20 | if (command) command.execute(client, message, args) 21 | } 22 | }) -------------------------------------------------------------------------------- /events/ready.js: -------------------------------------------------------------------------------- 1 | const Discord = require("discord.js") 2 | const { client, config } = require("../index.js") 3 | 4 | client.on("ready", () => { 5 | 6 | console.log("|\n| Advanced MassDM\n| Made by swirls#000\n|\n| Last Update: 16.6.2020\n|") 7 | 8 | client.user.setActivity(`Advanced MassDM v${config.version}`, { type: "PLAYING" }).catch(console.error); 9 | 10 | }) -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const discord = require("discord.js"); 2 | 3 | const config = require("./config.json"); 4 | const utils = require("./utils/util.js"); 5 | 6 | const client = new discord.Client(); 7 | const util = new utils.Utils(client, process.cwd()) 8 | module.exports = { client, config }; 9 | 10 | client.commands = new discord.Collection(); 11 | client.aliases = new discord.Collection(); 12 | 13 | util.loadModules("events"); 14 | util.loadModules("commands", true) 15 | 16 | client.login("YOUR TOKEN"); 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "autopartner", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "dependencies": { 7 | "dateformat": "^3.0.3", 8 | "discord.js": "^12.1.1" 9 | }, 10 | "devDependencies": {}, 11 | "scripts": { 12 | "test": "echo \"Error: no test specified\" && exit 1" 13 | }, 14 | "author": "", 15 | "license": "ISC" 16 | } 17 | -------------------------------------------------------------------------------- /utils/util.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const path = require("path"); 3 | module.exports.Utils = class Utils { 4 | 5 | constructor(client, project_folder) { 6 | this.client = client; 7 | this.project_folder = project_folder; 8 | } 9 | 10 | _findNested = (dir, pattern) => { 11 | 12 | let results = []; 13 | 14 | fs.readdirSync(dir).forEach(inner_dir => { 15 | 16 | inner_dir = path.resolve(dir, inner_dir); 17 | const stat = fs.statSync(inner_dir); 18 | 19 | if (stat.isDirectory()) { 20 | results = results.concat(this._findNested(inner_dir, pattern)); 21 | } 22 | 23 | if (stat.isFile() && inner_dir.endsWith(pattern)) { 24 | results.push(inner_dir); 25 | } 26 | 27 | }); 28 | 29 | return results; 30 | 31 | } 32 | 33 | loadModules = (dir, command=false) => { 34 | 35 | const jsFiles = this._findNested(this.project_folder + `${path.sep}${dir}${path.sep}`, ".js"); 36 | 37 | if (jsFiles.length <= 0) return console.log(`There are no ${command ? "commands" : "files"} to load.`); 38 | 39 | console.log(`Loading ${jsFiles.length} ${command ? "command" : "file"}${jsFiles.length <= 1 ? "" : "s"}...`); 40 | jsFiles.forEach(file => { 41 | const pull = require(file); 42 | 43 | if (command) { 44 | if (this.client.commands.get(pull.help.name)) console.warn(`CONFLICT: Duplicate commands found: ${pull.help.name}`); 45 | else this.client.commands.set(pull.help.name, pull); 46 | 47 | if (pull.help.aliases && typeof pull.help.aliases == "object") { 48 | pull.help.aliases.forEach(alias => { 49 | if (this.client.aliases.get(alias)) console.warn(`CONFLICT: Duplicate aliases found: ${alias}`); 50 | else if (this.client.commands.get(alias)) console.warn(`CONFLICT: Alias clases with command name: ${alias}`) 51 | else this.client.aliases.set(alias, pull.help.name); 52 | }); 53 | } 54 | } 55 | 56 | }); 57 | 58 | } 59 | 60 | loadCommand = (command, autoReload=true) => { 61 | 62 | if (!autoReload) { 63 | const commandFiles = this._findNested(this.project_folder + "\\commands\\", ".js"); 64 | command = commandFiles.filter(commandFile => commandFile.split("\\").pop() == `${command}.js`)[0]; 65 | if (!command) return "Unknown Command"; 66 | } 67 | 68 | try { 69 | 70 | const cmd = require(command); 71 | if (this.client.commands.get(cmd.help.name)) return "Command Already Loaded"; 72 | 73 | this.client.commands.set(cmd.help.name, cmd); 74 | cmd.help.aliases.forEach(alias => { 75 | this.client.aliases.set(alias, cmd.help.name); 76 | }); 77 | return "Command Loaded"; 78 | 79 | } catch { 80 | return "Error"; 81 | } 82 | 83 | } 84 | 85 | unloadCOmmand = (command, autoReload=true) => { 86 | 87 | if (!autoReload) { 88 | const commandFiles = this._findNested(this.project_folder + "\\commands\\", ".js"); 89 | command = commandFiles.filter(commandFile => commandFile.split("\\").pop() == `${command}.js`)[0]; 90 | if (!command) return "Unknown Command"; 91 | } 92 | 93 | try { 94 | const commandName = command.split("\\").pop().split(".")[0]; 95 | const res = this.client.commands.delete(commandName); 96 | if (!res) return "Command Not Loaded"; 97 | 98 | delete require.cache[require.resolve(command)]; 99 | return "Command Unloaded"; 100 | 101 | } catch (err) { 102 | return "Error"; 103 | } 104 | 105 | } 106 | 107 | reloadCommand = (commandName) => { 108 | 109 | const commandFiles = this._findNested(this.project_folder + "\\commands\\", ".js"); 110 | const command = commandFiles.filter(commandFile => commandFile.split("\\").pop() == `${commandName}.js`)[0]; 111 | if (!command) return "Unknown Command"; 112 | 113 | const res = this.unloadCOmmand(command); 114 | 115 | switch (res) { 116 | case "Command Unloaded": return this.loadCommand(command); 117 | default: return res; 118 | } 119 | 120 | } 121 | 122 | formatSeconds = (seconds) => { 123 | return new Date(seconds * 1000).toISOString().substr(11, 8) 124 | } 125 | 126 | replaceStrChar = (str, index, replacement) => { 127 | return str.substr(0, index) + replacement + str.substr(index + replacement.length); 128 | } 129 | 130 | } -------------------------------------------------------------------------------- /whitelist.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "ID1", 3 | "id2": "ID2" 4 | } 5 | --------------------------------------------------------------------------------