From 467dc136fff6d3bf5930b6cbfd863f3b133eedad Mon Sep 17 00:00:00 2001 From: Max Litruv Boonzaayer Date: Mon, 18 Mar 2019 06:23:27 +1100 Subject: [PATCH] cleaned up anagram.js, combined module exports. --- commands/anagram.js | 47 +++++----- commands/botname.js | 18 ++-- commands/changeprefix.js | 30 ++++--- commands/clear.js | 23 ++--- commands/diagnose.js | 176 +++++++++++++++++++------------------- commands/emotepage.js | 32 +++---- commands/getautoparent.js | 22 ++--- commands/getautovoice.js | 22 ++--- commands/help.js | 151 ++++++++++++++++---------------- commands/joke.js | 39 +++++---- commands/moveall.js | 30 ++++--- commands/permissions.js | 38 ++++---- commands/redditdoggo.js | 43 +++++----- commands/redditkitty.js | 43 +++++----- commands/redditlizard.js | 43 +++++----- commands/redditmlem.js | 43 +++++----- commands/redditsloth.js | 43 +++++----- commands/restart.js | 34 ++++---- commands/setautoparent.js | 20 +++-- commands/setautovoice.js | 20 +++-- commands/slap.js | 57 ++++++------ commands/stats.js | 35 ++++---- 22 files changed, 513 insertions(+), 496 deletions(-) diff --git a/commands/anagram.js b/commands/anagram.js index 678cd7f..fcd44f3 100644 --- a/commands/anagram.js +++ b/commands/anagram.js @@ -1,31 +1,32 @@ const fs = require('fs') const Discord = require('discord.js') -var request = require('request'); +const request = require('request'); +module.exports = { + name = "Anagram Finder", + alias =['anagram', 'nagaram'], + helptext = "finds anagrams up to 9 letters", + permissions =['VIEW_CHANNEL'], + args =['letters'], + command = (client, msg) => { -exports.name = "Anagram Finder" -exports.alias = ['anagram', 'nagaram'] -exports.helptext = "finds anagrams up to 9 letters" -exports.permissions = ['VIEW_CHANNEL'] -exports.args = ['letters'] -exports.command = (client, msg) => { - - var url = "http://www.anagramica.com/best/:"; + var url = "http://www.anagramica.com/best/:" - if (msg.suffix.length > 9){ - msg.reply("That anagram is too long. Max 9 Letters."); - return; - } - request({ - url: url + msg.suffix, - json: true - }, function (error, response, body) { - if (!error && response.statusCode === 200) { - var replystring = ""; - for (i = 0; i < body.best.length; i++) - replystring += body.best[i] + ', '; - msg.reply(replystring.substr(0, replystring.length - 2)); // Print the json response + if (msg.suffix.length > 9) { + msg.reply("That anagram is too long. Max 9 Letters.") + return; } - }); + request({ + url: url + msg.suffix, + json: true + }, (error, response, body) => { + if (!error && response.statusCode === 200) { + var replystring = "" + for (i = 0; i < body.best.length; i++) + replystring += body.best[i] + ', ' + msg.reply(replystring.substr(0, replystring.length - 2)) + } + }); + } } \ No newline at end of file diff --git a/commands/botname.js b/commands/botname.js index 7fb3235..693ae25 100644 --- a/commands/botname.js +++ b/commands/botname.js @@ -1,9 +1,11 @@ -exports.name = "Change <@476369946386104330>'s Name" -exports.alias = ['botname'] -exports.helptext = "Changes the bots name on the server" -exports.permissions = ["MANAGE_NICKNAMES"] -exports.args = ["new-name"] -exports.category = 'admin' -exports.command = (client, msg) => { - msg.guild.me.setNickname(msg.suffix); +module.exports = { + name = "Change <@476369946386104330>'s Name", + alias =['botname'], + helptext = "Changes the bots name on the server", + permissions =["MANAGE_NICKNAMES"], + args =["new-name"], + category = 'admin', + command = (client, msg) => { + msg.guild.me.setNickname(msg.suffix); + } } \ No newline at end of file diff --git a/commands/changeprefix.js b/commands/changeprefix.js index 883444f..a3ae486 100644 --- a/commands/changeprefix.js +++ b/commands/changeprefix.js @@ -1,16 +1,18 @@ -exports.name = "Change Prefix" -exports.alias = ['changeprefix','prefix'] -exports.helptext = "Changes the bots prefix for the server" -exports.permissions = ["ADMINISTRATOR"] -exports.category = 'admin' -exports.args = ["new-prefix"] -exports.command = (client, msg) => { - if (msg.suffix.length != 1) { - msg.reply("please only use 1 character") - return; +module.exports = { + name = "Change Prefix", + alias =['changeprefix', 'prefix'], + helptext = "Changes the bots prefix for the server", + permissions =["ADMINISTRATOR"], + category = 'admin', + args =["new-prefix"], + command = (client, msg) => { + if (msg.suffix.length != 1) { + msg.reply("please only use 1 character") + return; + } + client.database.set_setting(msg.guild.id, "prefix", msg.suffix) + client.cachedserversettings.filter(function (server) { + return server.guildID == msg.guild.id; + })[0].prefix = msg.suffix; } - client.database.set_setting(msg.guild.id, "prefix", msg.suffix) - client.cachedserversettings.filter(function (server) { - return server.guildID == msg.guild.id; - })[0].prefix = msg.suffix; } \ No newline at end of file diff --git a/commands/clear.js b/commands/clear.js index 0a6a181..f254384 100644 --- a/commands/clear.js +++ b/commands/clear.js @@ -1,12 +1,13 @@ -exports.name = "Clear Messages" -exports.alias = ['clear'] -exports.helptext = "Clears messages from the channel" -exports.helphide = false -exports.permissions = ['VIEW_CHANNEL'] -exports.args = ['number'] -exports.category = 'admin' - -exports.command = (client, msg) => { - console.log("Clearing: " + msg.suffix); - msg.channel.bulkDelete(parseInt(msg.suffix)+1); +module.exports = { + name = "Clear Messages", + alias =['clear'], + helptext = "Clears messages from the channel", + helphide = false, + permissions =['VIEW_CHANNEL'], + args =['number'], + category = 'admin', + command = (client, msg) => { + console.log("Clearing: " + msg.suffix); + msg.channel.bulkDelete(parseInt(msg.suffix) + 1); + } } \ No newline at end of file diff --git a/commands/diagnose.js b/commands/diagnose.js index 6e1e2f1..0157984 100644 --- a/commands/diagnose.js +++ b/commands/diagnose.js @@ -1,89 +1,91 @@ -exports.name = 'Self Diagnosis' -exports.alias = ['diagnose', 'webmd'] -exports.helptext = 'What cancer do you have today?' -exports.helphide = false -exports.permissions = ['READ_MESSAGES'] -exports.category = 'general' -exports.command = (client, msg) => { - switch(getRandomInt(0,25)) { - case 0: - msg.reply("I'm sorry, It's Cancer."); - break; - case 1: - msg.reply("I'm sorry, It's Lukemia."); - break; - case 2: - msg.reply("I'm sorry, It's AIDS."); - break; - case 3: - msg.reply("I'm sorry, It's Lesch-Nyhan."); - break; - case 4: - msg.reply("I'm sorry, It's Heart Disease."); - break; - case 5: - msg.reply("I'm sorry, It's Ebola."); - break; - case 6: - msg.reply("I'm sorry, It's Addison’s disease."); - break; - case 7: - msg.reply("I'm sorry, It's Asthma."); - break; - case 8: - msg.reply("I'm sorry, It's Cardiac failure."); - break; - case 9: - msg.reply("I'm sorry, It's Cardiomyopathy."); - break; - case 10: - msg.reply("I'm sorry, It's Chronic obstructive pulmonary disorder."); - break; - case 11: - msg.reply("I'm sorry, It's Chronic renal disease."); - break; - case 12: - msg.reply("I'm sorry, It's Coronary artery disease."); - break; - case 13: - msg.reply("I'm sorry, It's Crohn’s disease."); - break; - case 14: - msg.reply("I'm sorry, It's Diabetes."); - break; - case 15: - msg.reply("I'm sorry, It's Glaucoma."); - break; - case 16: - msg.reply("I'm sorry, It's Haemophilia."); - break; - case 17: - msg.reply("I'm sorry, It's Hypertension."); - break; - case 18: - msg.reply("I'm sorry, It's Hypothyroidism."); - break; - case 19: - msg.reply("I'm sorry, It's Multiple sclerosis."); - break; - case 20: - msg.reply("I'm sorry, It's Parkinson’s disease."); - break; - case 21: - msg.reply("I'm sorry, It's Rheumatoid arthritis."); - break; - case 22: - msg.reply("I'm sorry, It's Schizophrenia."); - break; - case 23: - msg.reply("I'm sorry, It's Systemic lupus erythematosus."); - break; - case 24: - msg.reply("I'm sorry, It's Ulcerative colitis."); - break; - case 25: - msg.reply("I'm sorry, It's Bipolar Mood Disorder."); - break; +module.exports = { + name = 'Self Diagnosis', + alias =['diagnose', 'webmd'], + helptext = 'What cancer do you have today?', + helphide = false, + permissions =['READ_MESSAGES'], + category = 'general', + command = (client, msg) => { + switch (getRandomInt(0, 25)) { + case 0: + msg.reply("I'm sorry, It's Cancer."); + break; + case 1: + msg.reply("I'm sorry, It's Lukemia."); + break; + case 2: + msg.reply("I'm sorry, It's AIDS."); + break; + case 3: + msg.reply("I'm sorry, It's Lesch-Nyhan."); + break; + case 4: + msg.reply("I'm sorry, It's Heart Disease."); + break; + case 5: + msg.reply("I'm sorry, It's Ebola."); + break; + case 6: + msg.reply("I'm sorry, It's Addison’s disease."); + break; + case 7: + msg.reply("I'm sorry, It's Asthma."); + break; + case 8: + msg.reply("I'm sorry, It's Cardiac failure."); + break; + case 9: + msg.reply("I'm sorry, It's Cardiomyopathy."); + break; + case 10: + msg.reply("I'm sorry, It's Chronic obstructive pulmonary disorder."); + break; + case 11: + msg.reply("I'm sorry, It's Chronic renal disease."); + break; + case 12: + msg.reply("I'm sorry, It's Coronary artery disease."); + break; + case 13: + msg.reply("I'm sorry, It's Crohn’s disease."); + break; + case 14: + msg.reply("I'm sorry, It's Diabetes."); + break; + case 15: + msg.reply("I'm sorry, It's Glaucoma."); + break; + case 16: + msg.reply("I'm sorry, It's Haemophilia."); + break; + case 17: + msg.reply("I'm sorry, It's Hypertension."); + break; + case 18: + msg.reply("I'm sorry, It's Hypothyroidism."); + break; + case 19: + msg.reply("I'm sorry, It's Multiple sclerosis."); + break; + case 20: + msg.reply("I'm sorry, It's Parkinson’s disease."); + break; + case 21: + msg.reply("I'm sorry, It's Rheumatoid arthritis."); + break; + case 22: + msg.reply("I'm sorry, It's Schizophrenia."); + break; + case 23: + msg.reply("I'm sorry, It's Systemic lupus erythematosus."); + break; + case 24: + msg.reply("I'm sorry, It's Ulcerative colitis."); + break; + case 25: + msg.reply("I'm sorry, It's Bipolar Mood Disorder."); + break; + } } } @@ -91,4 +93,4 @@ function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive - } \ No newline at end of file +} \ No newline at end of file diff --git a/commands/emotepage.js b/commands/emotepage.js index 31b78ac..01fb187 100644 --- a/commands/emotepage.js +++ b/commands/emotepage.js @@ -1,18 +1,20 @@ -exports.name = "Emote Page Test" -exports.alias = ['emotetest'] -exports.helptext = "testing for emote responses" -exports.helphide = true; -exports.command = (client, msg) => { +module.exports = { + name = "Emote Page Test", + alias =['emotetest'], + helptext = "testing for emote responses", + helphide = true;, + command = (client, msg) => { - msg.reply ("testing emote thing") - .then(sent => { - sent.react('555213405217226776').then( - () => message.react('555213429200388116')); - const filter = (reaction, user) => user.id === msg.member.user.id + msg.reply("testing emote thing") + .then(sent => { + sent.react('555213405217226776').then( + () => message.react('555213429200388116')); + const filter = (reaction, user) => user.id === msg.member.user.id - sent.awaitReactions(filter) - .then(collected => console.log(`Collected ${collected.size} reactions`)) - .catch(console.error); - }) - return true; + sent.awaitReactions(filter) + .then(collected => console.log(`Collected ${collected.size} reactions`)) + .catch(console.error); + }) + return true; + } } \ No newline at end of file diff --git a/commands/getautoparent.js b/commands/getautoparent.js index be0238e..f60495d 100644 --- a/commands/getautoparent.js +++ b/commands/getautoparent.js @@ -1,11 +1,13 @@ -exports.name = 'Get auto parent' -exports.alias = ['getautoparent'] -exports.helptext = 'gets the auto creation channel' -exports.helphide = false -exports.permissions = ['ADMINISTRATOR'] -exports.category = 'admin' -exports.command = (client, msg) => { - client.database.get_setting("autoParent", msg.guild.id).then((r) => { - msg.reply(`${r} - ${msg.guild.channels.get(r).name}`); - }); +module.exports = { + name = 'Get auto parent', + alias =['getautoparent'], + helptext = 'gets the auto creation channel', + helphide = false, + permissions =['ADMINISTRATOR'], + category = 'admin', + command = (client, msg) => { + client.database.get_setting("autoParent", msg.guild.id).then((r) => { + msg.reply(`${r} - ${msg.guild.channels.get(r).name}`); + }); + } } \ No newline at end of file diff --git a/commands/getautovoice.js b/commands/getautovoice.js index abcb52e..495685a 100644 --- a/commands/getautovoice.js +++ b/commands/getautovoice.js @@ -1,12 +1,14 @@ -exports.name = 'Get auto voice' -exports.alias = ['getautovoice'] -exports.helptext = 'Set the auto-sorting channel' -exports.helphide = false -exports.permissions = ['READ_MESSAGES'] -exports.category = 'admin' -exports.command = (client, msg) => { - client.database.get_setting("autoVoice", msg.guild.id).then((r) => { - msg.reply(`${r} - ${msg.guild.channels.get(r).name}`); - }); +module.exports = { + name = 'Get auto voice', + alias =['getautovoice'], + helptext = 'Set the auto-sorting channel', + helphide = false, + permissions =['READ_MESSAGES'], + category = 'admin', + command = (client, msg) => { + client.database.get_setting("autoVoice", msg.guild.id).then((r) => { + msg.reply(`${r} - ${msg.guild.channels.get(r).name}`); + }); + } } \ No newline at end of file diff --git a/commands/help.js b/commands/help.js index 370d071..6b2964f 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,91 +1,86 @@ const fs = require('fs') const Discord = require('discord.js') -exports.name = "Help file" -exports.alias = ['help', '?'] -exports.helptext = "Runs this help menu" -exports.permissions = ['VIEW_CHANNEL'] -exports.args = ['(general)/music/admin'] -exports.command = (client, msg) => { - - - fs.readdir("./commands/", function (err, items) { - var embed = new Discord.RichEmbed - embed.color = 0x0ca9fe - //embed.setAuthor("DAdmin", "https://cdn.discordapp.com/avatars/476369946386104330/833d7f2fcae8a31f6c74551c8f703ca8.png", "https://litruv.com") - - - var suffix = msg.suffix; - var lookingfor = 0 - if (msg.suffix.toLowerCase() == "admin"){ - lookingfor = 1 - suffix = "admin" - } else if (msg.suffix.toLowerCase() == "music"){ - lookingfor = 2 - suffix = "music" - } else { - lookingfor = 0; - suffix = "general" - - } - - var description = ""; - switch(lookingfor){ - case 0: - description += "General Commands" - break; - case 1: - description += "Admin Commands" - break; - case 2: - description += "Music Commands" - break - } - - description += "\n\n" - - for (var i = 0; i < items.length; i++) { - var reqcommand = require("./" + items[i]) - if (reqcommand.helphide) - continue; - if (reqcommand.category == undefined) - reqcommand.category = 'general' +module.exports = { + name = "Help file", + alias =['help', '?'], + helptext = "Runs this help menu", + permissions =['VIEW_CHANNEL'], + args =['(general)/music/admin'], + command = (client, msg) => { + fs.readdir("./commands/", function (err, items) { + var embed = new Discord.RichEmbed + embed.color = 0x0ca9fe + //embed.setAuthor("DAdmin", "https://cdn.discordapp.com/avatars/476369946386104330/833d7f2fcae8a31f6c74551c8f703ca8.png", "https://litruv.com") + var suffix = msg.suffix; + var lookingfor = 0 + if (msg.suffix.toLowerCase() == "admin") { + lookingfor = 1 + suffix = "admin" + } else if (msg.suffix.toLowerCase() == "music") { + lookingfor = 2 + suffix = "music" + } else { + lookingfor = 0; + suffix = "general" - if (reqcommand.category != suffix) - continue; - - - - description += "**" + reqcommand.name + "** - *" + reqcommand.helptext + "* \n " - args = ""; - - if (reqcommand.args != undefined) - for (var z = 0; z < reqcommand.args.length; z++) { - args += "<" + reqcommand.args[z] + ">" - } - description += "```apache\n" - for (var z = 0; z < reqcommand.alias.length; z++) { - description += client.cachedserversettings.filter(function (server) { - return server.guildID == msg.guild.id; - })[0].prefix - - description += reqcommand.alias[z] + " "; - if (z != reqcommand.alias.length -1) - description += "/ "; } - description += "\n" + args + "```" - if (i != items.length -1) - description += "\n"; + var description = ""; + switch (lookingfor) { + case 0: + description += "General Commands" + break; + case 1: + description += "Admin Commands" + break; + case 2: + description += "Music Commands" + break + } - delete require.cache[require.resolve('./' + items[i])] + description += "\n\n" - } - embed.setDescription(description) + for (var i = 0; i < items.length; i++) { + var reqcommand = require("./" + items[i]) + if (reqcommand.helphide) + continue; + if (reqcommand.category == undefined) + reqcommand.category = 'general' + if (reqcommand.category != suffix) + continue; - msg.channel.send(embed); - }) + description += "**" + reqcommand.name + "** - *" + reqcommand.helptext + "* \n " + args = ""; + if (reqcommand.args != undefined) + for (var z = 0; z < reqcommand.args.length; z++) { + args += "<" + reqcommand.args[z] + ">" + } + description += "```apache\n" + for (var z = 0; z < reqcommand.alias.length; z++) { + description += client.cachedserversettings.filter(function (server) { + return server.guildID == msg.guild.id; + })[0].prefix + + description += reqcommand.alias[z] + " "; + if (z != reqcommand.alias.length - 1) + description += "/ "; + } + + description += "\n" + args + "```" + if (i != items.length - 1) + description += "\n"; + + delete require.cache[require.resolve('./' + items[i])] + + } + embed.setDescription(description) + + msg.channel.send(embed); + }) + + } } \ No newline at end of file diff --git a/commands/joke.js b/commands/joke.js index 67f4cbf..9beede9 100644 --- a/commands/joke.js +++ b/commands/joke.js @@ -1,29 +1,30 @@ var request = require('request'); var url = "https://www.reddit.com/r/dadjokes/hot/.json?limit=100"; +module.exports = { + name = 'joke', + alias =['joke'], + helptext = 'Fresh dad jokes from reddit.com/r/dadjokes', + helphide = false, + permissions =['READ_MESSAGES'], + category = 'general', + command = (client, msg) => { + request({ + url: url, + json: true + }, function (error, response, body) { + if (!error && response.statusCode === 200) { -exports.name = 'joke' -exports.alias = ['joke'] -exports.helptext = 'Fresh dad jokes from reddit.com/r/dadjokes' -exports.helphide = false -exports.permissions = ['READ_MESSAGES'] -exports.category = 'general' -exports.command = (client, msg) => { - request({ - url: url, - json: true - }, function (error, response, body) { - if (!error && response.statusCode === 200) { - - //var parsed = JSON.parse(response) - var jokenumber = getRandomInt(0, 25); - msg.reply(body.data.children[jokenumber].data.title + " " + body.data.children[jokenumber].data.selftext); // Print the json response - } - }); + //var parsed = JSON.parse(response) + var jokenumber = getRandomInt(0, 25); + msg.reply(body.data.children[jokenumber].data.title + " " + body.data.children[jokenumber].data.selftext); // Print the json response + } + }); + } } function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive - } \ No newline at end of file +} \ No newline at end of file diff --git a/commands/moveall.js b/commands/moveall.js index 0496de5..bf40313 100644 --- a/commands/moveall.js +++ b/commands/moveall.js @@ -1,16 +1,18 @@ -exports.name = 'Move all' -exports.alias = ['moveall'] -exports.helptext = 'Moves all people from one Voice Chat, to the next' -exports.helphide = false -exports.permissions = ['MOVE_MEMBERS'] -exports.args = ['ChannelID', 'ChannelID'] -exports.category = 'admin' -exports.command = (client, msg) => { - cleaner = msg.cleanContent.replace(/\s\s+/g, ' '); - chans = cleaner.split(' '); - console.log("From: " + chans[1]); - msg.guild.channels.get(chans[1]).members.forEach(m => { - m.setVoiceChannel(chans[2]); - }); +module.exports = { + name = 'Move all', + alias =['moveall'], + helptext = 'Moves all people from one Voice Chat, to the next', + helphide = false, + permissions =['MOVE_MEMBERS'], + args =['ChannelID', 'ChannelID'], + category = 'admin', + command = (client, msg) => { + cleaner = msg.cleanContent.replace(/\s\s+/g, ' '); + chans = cleaner.split(' '); + console.log("From: " + chans[1]); + msg.guild.channels.get(chans[1]).members.forEach(m => { + m.setVoiceChannel(chans[2]); + }); + } } \ No newline at end of file diff --git a/commands/permissions.js b/commands/permissions.js index af49ca8..fb3e277 100644 --- a/commands/permissions.js +++ b/commands/permissions.js @@ -1,21 +1,23 @@ -exports.name = 'Permissions' -exports.alias = ['permissions'] -exports.helptext = 'Check permissions for user' -exports.helphide = false -exports.permissions = ['MANAGE_ROLES_OR_PERMISSIONS'] -exports.args = ['@Tag'] -exports.category = 'admin' -exports.command = (client, msg) => { - if(msg.mentions.members.array().length != 1) - return; - - var perms = msg.mentions.members.first().permissions.toArray(true); +module.exports = { + name = 'Permissions', + alias =['permissions'], + helptext = 'Check permissions for user', + helphide = false, + permissions =['MANAGE_ROLES_OR_PERMISSIONS'], + args =['@Tag'], + category = 'admin', + command = (client, msg) => { + if (msg.mentions.members.array().length != 1) + return; - var message = ""; - for (var i = 0; i < perms.length; i++) { - message += perms[i]; - if (i != perms.length -1) - message += ", "; + var perms = msg.mentions.members.first().permissions.toArray(true); + + var message = ""; + for (var i = 0; i < perms.length; i++) { + message += perms[i]; + if (i != perms.length - 1) + message += ", "; + } + msg.reply(message); } - msg.reply(message); } \ No newline at end of file diff --git a/commands/redditdoggo.js b/commands/redditdoggo.js index 531187d..8409d77 100644 --- a/commands/redditdoggo.js +++ b/commands/redditdoggo.js @@ -1,29 +1,30 @@ var request = require('request'); var url = "https://www.reddit.com/r/doggos/hot/.json?limit=100"; -exports.name = 'Doggo' -exports.alias = ['doggo'] -exports.helptext = 'Inserts good boye from reddit/r/doggos' -exports.helphide = false -exports.permissions = ['READ_MESSAGES'] -exports.category = 'general' -exports.command = (client, msg) => { - request({ - url: url, - json: true - }, function (error, response, body) { - if (!error && response.statusCode === 200) { - var sent = false; - while (!sent) { - var jokenumber = getRandomInt(1, 25); - if (body.data.children[jokenumber].data.url.endsWith(".jpg")) - { - msg.channel.send({file:body.data.children[jokenumber].data.url}); - sent = true; +module.exports = { + name = 'Doggo', + alias =['doggo'], + helptext = 'Inserts good boye from reddit/r/doggos', + helphide = false, + permissions =['READ_MESSAGES'], + category = 'general', + command = (client, msg) => { + request({ + url: url, + json: true + }, function (error, response, body) { + if (!error && response.statusCode === 200) { + var sent = false; + while (!sent) { + var jokenumber = getRandomInt(1, 25); + if (body.data.children[jokenumber].data.url.endsWith(".jpg")) { + msg.channel.send({ file: body.data.children[jokenumber].data.url }); + sent = true; + } } } - } - }); + }); + } } function getRandomInt(min, max) { diff --git a/commands/redditkitty.js b/commands/redditkitty.js index 09e56d8..9b95e6d 100644 --- a/commands/redditkitty.js +++ b/commands/redditkitty.js @@ -1,29 +1,30 @@ var request = require('request'); var url = "https://www.reddit.com/r/cats/hot/.json?limit=100"; -exports.name = 'Kitty' -exports.alias = ['kitty'] -exports.helptext = 'Inserts good boye from reddit/r/cats' -exports.helphide = false -exports.permissions = ['READ_MESSAGES'] -exports.category = 'general' -exports.command = (client, msg) => { - request({ - url: url, - json: true - }, function (error, response, body) { - if (!error && response.statusCode === 200) { - var sent = false; - while (!sent) { - var jokenumber = getRandomInt(1, 25); - if (body.data.children[jokenumber].data.url.endsWith(".jpg")) - { - msg.channel.send({file:body.data.children[jokenumber].data.url}); - sent = true; +module.exports = { + name = 'Kitty', + alias =['kitty'], + helptext = 'Inserts good boye from reddit/r/cats', + helphide = false, + permissions =['READ_MESSAGES'], + category = 'general', + command = (client, msg) => { + request({ + url: url, + json: true + }, function (error, response, body) { + if (!error && response.statusCode === 200) { + var sent = false; + while (!sent) { + var jokenumber = getRandomInt(1, 25); + if (body.data.children[jokenumber].data.url.endsWith(".jpg")) { + msg.channel.send({ file: body.data.children[jokenumber].data.url }); + sent = true; + } } } - } - }); + }); + } } function getRandomInt(min, max) { diff --git a/commands/redditlizard.js b/commands/redditlizard.js index 1e71b77..1457491 100644 --- a/commands/redditlizard.js +++ b/commands/redditlizard.js @@ -1,29 +1,30 @@ var request = require('request'); var url = "https://www.reddit.com/r/lizards/hot/.json?limit=100"; -exports.name = 'Lizard' -exports.alias = ['lizard'] -exports.helptext = 'Inserts good boye from reddit/r/lizards' -exports.helphide = false -exports.permissions = ['READ_MESSAGES'] -exports.category = 'general' -exports.command = (client, msg) => { - request({ - url: url, - json: true - }, function (error, response, body) { - if (!error && response.statusCode === 200) { - var sent = false; - while (!sent) { - var jokenumber = getRandomInt(1, 25); - if (body.data.children[jokenumber].data.url.endsWith(".jpg")) - { - msg.channel.send({file:body.data.children[jokenumber].data.url}); - sent = true; +module.exports = { + name = 'Lizard', + alias =['lizard'], + helptext = 'Inserts good boye from reddit/r/lizards', + helphide = false, + permissions =['READ_MESSAGES'], + category = 'general', + command = (client, msg) => { + request({ + url: url, + json: true + }, function (error, response, body) { + if (!error && response.statusCode === 200) { + var sent = false; + while (!sent) { + var jokenumber = getRandomInt(1, 25); + if (body.data.children[jokenumber].data.url.endsWith(".jpg")) { + msg.channel.send({ file: body.data.children[jokenumber].data.url }); + sent = true; + } } } - } - }); + }); + } } function getRandomInt(min, max) { diff --git a/commands/redditmlem.js b/commands/redditmlem.js index a40d124..6bae154 100644 --- a/commands/redditmlem.js +++ b/commands/redditmlem.js @@ -1,29 +1,30 @@ var request = require('request'); var url = "https://www.reddit.com/r/mlem/hot/.json?limit=100"; -exports.name = 'Mlem' -exports.alias = ['mlem'] -exports.helptext = 'Inserts good boye from reddit/r/mlem' -exports.helphide = false -exports.permissions = ['READ_MESSAGES'] -exports.category = 'general' -exports.command = (client, msg) => { - request({ - url: url, - json: true - }, function (error, response, body) { - if (!error && response.statusCode === 200) { - var sent = false; - while (!sent) { - var jokenumber = getRandomInt(1, 25); - if (body.data.children[jokenumber].data.url.endsWith(".jpg")) - { - msg.channel.send({file:body.data.children[jokenumber].data.url}); - sent = true; +module.exports = { + name = 'Mlem', + alias =['mlem'], + helptext = 'Inserts good boye from reddit/r/mlem', + helphide = false, + permissions =['READ_MESSAGES'], + category = 'general', + command = (client, msg) => { + request({ + url: url, + json: true + }, function (error, response, body) { + if (!error && response.statusCode === 200) { + var sent = false; + while (!sent) { + var jokenumber = getRandomInt(1, 25); + if (body.data.children[jokenumber].data.url.endsWith(".jpg")) { + msg.channel.send({ file: body.data.children[jokenumber].data.url }); + sent = true; + } } } - } - }); + }); + } } function getRandomInt(min, max) { diff --git a/commands/redditsloth.js b/commands/redditsloth.js index f98ae2f..2ef22c9 100644 --- a/commands/redditsloth.js +++ b/commands/redditsloth.js @@ -1,29 +1,30 @@ var request = require('request'); var url = "https://www.reddit.com/r/sloths/hot/.json?limit=100"; -exports.name = 'Sloth' -exports.alias = ['sloth'] -exports.helptext = 'Inserts good boye from reddit/r/sloths' -exports.helphide = false -exports.permissions = ['READ_MESSAGES'] -exports.category = 'general' -exports.command = (client, msg) => { - request({ - url: url, - json: true - }, function (error, response, body) { - if (!error && response.statusCode === 200) { - var sent = false; - while (!sent) { - var jokenumber = getRandomInt(1, 25); - if (body.data.children[jokenumber].data.url.endsWith(".jpg")) - { - msg.channel.send({file:body.data.children[jokenumber].data.url}); - sent = true; +module.exports = { + name = 'Sloth', + alias =['sloth'], + helptext = 'Inserts good boye from reddit/r/sloths', + helphide = false, + permissions =['READ_MESSAGES'], + category = 'general', + command = (client, msg) => { + request({ + url: url, + json: true + }, function (error, response, body) { + if (!error && response.statusCode === 200) { + var sent = false; + while (!sent) { + var jokenumber = getRandomInt(1, 25); + if (body.data.children[jokenumber].data.url.endsWith(".jpg")) { + msg.channel.send({ file: body.data.children[jokenumber].data.url }); + sent = true; + } } } - } - }); + }); + } } function getRandomInt(min, max) { diff --git a/commands/restart.js b/commands/restart.js index 57ca0c6..cb09991 100644 --- a/commands/restart.js +++ b/commands/restart.js @@ -1,18 +1,20 @@ -exports.name = 'Restart' -exports.alias = ['restart'] -exports.helptext = 'Restart DAdmin' -exports.helphide = true -exports.permissions = ['READ_MESSAGES'] -exports.category = 'admin' -exports.command = (client, msg) => { - var r = "220772082055774210"; - if (msg.member.id == r) { - msg.react("✅"); - msg.reply("Shutting Down.. 😭"); - setTimeout(function () { - process.exit(22); - }, 1000); - } else { - msg.react("❌"); +module.exports = { + name = 'Restart', + alias =['restart'], + helptext = 'Restart DAdmin', + helphide = true, + permissions =['READ_MESSAGES'], + category = 'admin', + command = (client, msg) => { + var r = "220772082055774210"; + if (msg.member.id == r) { + msg.react("✅"); + msg.reply("Shutting Down.. 😭"); + setTimeout(function () { + process.exit(22); + }, 1000); + } else { + msg.react("❌"); + } } } \ No newline at end of file diff --git a/commands/setautoparent.js b/commands/setautoparent.js index 8ff3d48..e8b2d88 100644 --- a/commands/setautoparent.js +++ b/commands/setautoparent.js @@ -1,10 +1,12 @@ -exports.name = 'Set auto parent' -exports.alias = ['setautoparent'] -exports.helptext = 'sets the auto creation category' -exports.helphide = false -exports.permissions = ['ADMINISTRATOR'] -exports.args = ['VChannelID'] -exports.category = 'admin' -exports.command = (client, msg) => { - database.set_setting(msg.guild.id, "autoParent", msg.suffix); +module.exports = { + name = 'Set auto parent', + alias =['setautoparent'], + helptext = 'sets the auto creation category', + helphide = false, + permissions =['ADMINISTRATOR'], + args =['VChannelID'], + category = 'admin', + command = (client, msg) => { + database.set_setting(msg.guild.id, "autoParent", msg.suffix); + } } \ No newline at end of file diff --git a/commands/setautovoice.js b/commands/setautovoice.js index 42e6a70..8a8e435 100644 --- a/commands/setautovoice.js +++ b/commands/setautovoice.js @@ -1,10 +1,12 @@ -exports.name = 'Set auto voice' -exports.alias = ['setautovoice'] -exports.helptext = 'Sets the auto-sorting voice channel' -exports.helphide = false -exports.permissions = ['ADMINISTRATOR'] -exports.args = ['VChannelID'] -exports.category = 'admin' -exports.command = (client, msg) => { - client.database.set_setting(msg.guild.id, "autoVoice", msg.suffix); +module.exports = { + name = 'Set auto voice', + alias =['setautovoice'], + helptext = 'Sets the auto-sorting voice channel', + helphide = false, + permissions =['ADMINISTRATOR'], + args =['VChannelID'], + category = 'admin', + command = (client, msg) => { + client.database.set_setting(msg.guild.id, "autoVoice", msg.suffix); + } } \ No newline at end of file diff --git a/commands/slap.js b/commands/slap.js index 26813a6..3b5346b 100644 --- a/commands/slap.js +++ b/commands/slap.js @@ -1,33 +1,28 @@ -exports.name = 'Slap' -exports.alias = ['slap'] -exports.helptext = 'Slaps users to empty channels and back again' -exports.helphide = false -exports.permissions = ['MOVE_MEMBERS'] -exports.args = ['@Tag'] -exports.category = 'admin' -exports.command = (client, msg) => { - client.database.get_setting("autoVoice", msg.guild.id).then((autochan) => { - var itemsProcessed = 0; - var cid = msg.mentions.members.first().voiceChannelID; - - msg.guild.channels.filter(isVoice).forEach(element => { - itemsProcessed++; - - if (itemsProcessed <= 8) { - if (element.id != autochan) { - if (element.members.array().length == 0); - msg.mentions.members.first().setVoiceChannel(element.id); - +module.exports = { + name = 'Slap', + alias =['slap'], + helptext = 'Slaps users to empty channels and back again', + helphide = false, + permissions =['MOVE_MEMBERS'], + args =['@Tag'], + category = 'admin', + command = (client, msg) => { + client.database.get_setting("autoVoice", msg.guild.id).then((autochan) => { + var itemsProcessed = 0 + var cid = msg.mentions.members.first().voiceChannelID + msg.guild.channels.filter(c => value.type == "voice").forEach(element => { + itemsProcessed++ + if (itemsProcessed <= 8) { + if (element.id != autochan) { + if (element.members.array().length == 0) + msg.mentions.members.first().setVoiceChannel(element.id) + } + if (itemsProcessed >= msg.guild.channels.filter(c => value.type == "voice").array().length || itemsProcessed >= 8) { + msg.mentions.members.first().setVoiceChannel(cid) + } } - if (itemsProcessed >= msg.guild.channels.filter(isVoice).array().length || itemsProcessed >= 8) { - msg.mentions.members.first().setVoiceChannel(cid); - } - } - }); - }); + }) + }) -} - -function isVoice(value) { - return value.type == "voice"; -} + } +} \ No newline at end of file diff --git a/commands/stats.js b/commands/stats.js index 9713bcc..d7528aa 100644 --- a/commands/stats.js +++ b/commands/stats.js @@ -1,25 +1,23 @@ -exports.name = 'Stats for DAdmin' -exports.alias = ['stats'] -exports.helptext = 'Metrics on DAdmin, uptime, users, servers' -exports.helphide = false -exports.permissions = ['READ_MESSAGES'] -exports.category = 'general' -exports.command = (client, msg) => { - var users = 0; - for (var i = 0; i < client.guilds.array().length; i++){ - users += client.guilds.array()[i].members.array().length; - } - - msg.reply("Running DAdmin for " + millisecondsToStr(client.uptime) + " on " + client.guilds.array().length + " servers for " + users + " users, since 09 Aug 2018"); +module.exports = { + name = 'Stats for DAdmin', + alias =['stats'], + helptext = 'Metrics on DAdmin, uptime, users, servers', + helphide = false, + permissions =['READ_MESSAGES'], + category = 'general', + command = (client, msg) => { + var users = 0; + for (var i = 0; i < client.guilds.array().length; i++) { + users += client.guilds.array()[i].members.array().length; + } + msg.reply("Running DAdmin for " + millisecondsToStr(client.uptime) + " on " + client.guilds.array().length + " servers for " + users + " users, since 09 Aug 2018"); + } } +function millisecondsToStr(milliseconds) { -function millisecondsToStr (milliseconds) { - // TIP: to find current time in milliseconds, use: - // var current_time_milliseconds = new Date().getTime(); - - function numberEnding (number) { + function numberEnding(number) { return (number > 1) ? 's' : ''; } @@ -47,4 +45,3 @@ function millisecondsToStr (milliseconds) { } return 'less than a second'; //'just now' //or other string you like; } -