cleaned up anagram.js, combined module exports.

This commit is contained in:
2019-03-18 06:23:27 +11:00
parent 7d11f13e30
commit 467dc136ff
22 changed files with 513 additions and 496 deletions

View File

@@ -1,31 +1,32 @@
const fs = require('fs') const fs = require('fs')
const Discord = require('discord.js') 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" var url = "http://www.anagramica.com/best/:"
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/:"; if (msg.suffix.length > 9) {
msg.reply("That anagram is too long. Max 9 Letters.")
if (msg.suffix.length > 9){ return;
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
} }
}); 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))
}
});
}
} }

View File

@@ -1,9 +1,11 @@
exports.name = "Change <@476369946386104330>'s Name" module.exports = {
exports.alias = ['botname'] name = "Change <@476369946386104330>'s Name",
exports.helptext = "Changes the bots name on the server" alias =['botname'],
exports.permissions = ["MANAGE_NICKNAMES"] helptext = "Changes the bots name on the server",
exports.args = ["new-name"] permissions =["MANAGE_NICKNAMES"],
exports.category = 'admin' args =["new-name"],
exports.command = (client, msg) => { category = 'admin',
msg.guild.me.setNickname(msg.suffix); command = (client, msg) => {
msg.guild.me.setNickname(msg.suffix);
}
} }

View File

@@ -1,16 +1,18 @@
exports.name = "Change Prefix" module.exports = {
exports.alias = ['changeprefix','prefix'] name = "Change Prefix",
exports.helptext = "Changes the bots prefix for the server" alias =['changeprefix', 'prefix'],
exports.permissions = ["ADMINISTRATOR"] helptext = "Changes the bots prefix for the server",
exports.category = 'admin' permissions =["ADMINISTRATOR"],
exports.args = ["new-prefix"] category = 'admin',
exports.command = (client, msg) => { args =["new-prefix"],
if (msg.suffix.length != 1) { command = (client, msg) => {
msg.reply("please only use 1 character") if (msg.suffix.length != 1) {
return; 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;
} }

View File

@@ -1,12 +1,13 @@
exports.name = "Clear Messages" module.exports = {
exports.alias = ['clear'] name = "Clear Messages",
exports.helptext = "Clears messages from the channel" alias =['clear'],
exports.helphide = false helptext = "Clears messages from the channel",
exports.permissions = ['VIEW_CHANNEL'] helphide = false,
exports.args = ['number'] permissions =['VIEW_CHANNEL'],
exports.category = 'admin' args =['number'],
category = 'admin',
exports.command = (client, msg) => { command = (client, msg) => {
console.log("Clearing: " + msg.suffix); console.log("Clearing: " + msg.suffix);
msg.channel.bulkDelete(parseInt(msg.suffix)+1); msg.channel.bulkDelete(parseInt(msg.suffix) + 1);
}
} }

View File

@@ -1,89 +1,91 @@
exports.name = 'Self Diagnosis' module.exports = {
exports.alias = ['diagnose', 'webmd'] name = 'Self Diagnosis',
exports.helptext = 'What cancer do you have today?' alias =['diagnose', 'webmd'],
exports.helphide = false helptext = 'What cancer do you have today?',
exports.permissions = ['READ_MESSAGES'] helphide = false,
exports.category = 'general' permissions =['READ_MESSAGES'],
exports.command = (client, msg) => { category = 'general',
switch(getRandomInt(0,25)) { command = (client, msg) => {
case 0: switch (getRandomInt(0, 25)) {
msg.reply("I'm sorry, It's Cancer."); case 0:
break; msg.reply("I'm sorry, It's Cancer.");
case 1: break;
msg.reply("I'm sorry, It's Lukemia."); case 1:
break; msg.reply("I'm sorry, It's Lukemia.");
case 2: break;
msg.reply("I'm sorry, It's AIDS."); case 2:
break; msg.reply("I'm sorry, It's AIDS.");
case 3: break;
msg.reply("I'm sorry, It's Lesch-Nyhan."); case 3:
break; msg.reply("I'm sorry, It's Lesch-Nyhan.");
case 4: break;
msg.reply("I'm sorry, It's Heart Disease."); case 4:
break; msg.reply("I'm sorry, It's Heart Disease.");
case 5: break;
msg.reply("I'm sorry, It's Ebola."); case 5:
break; msg.reply("I'm sorry, It's Ebola.");
case 6: break;
msg.reply("I'm sorry, It's Addisons disease."); case 6:
break; msg.reply("I'm sorry, It's Addisons disease.");
case 7: break;
msg.reply("I'm sorry, It's Asthma."); case 7:
break; msg.reply("I'm sorry, It's Asthma.");
case 8: break;
msg.reply("I'm sorry, It's Cardiac failure."); case 8:
break; msg.reply("I'm sorry, It's Cardiac failure.");
case 9: break;
msg.reply("I'm sorry, It's Cardiomyopathy."); case 9:
break; msg.reply("I'm sorry, It's Cardiomyopathy.");
case 10: break;
msg.reply("I'm sorry, It's Chronic obstructive pulmonary disorder."); case 10:
break; msg.reply("I'm sorry, It's Chronic obstructive pulmonary disorder.");
case 11: break;
msg.reply("I'm sorry, It's Chronic renal disease."); case 11:
break; msg.reply("I'm sorry, It's Chronic renal disease.");
case 12: break;
msg.reply("I'm sorry, It's Coronary artery disease."); case 12:
break; msg.reply("I'm sorry, It's Coronary artery disease.");
case 13: break;
msg.reply("I'm sorry, It's Crohns disease."); case 13:
break; msg.reply("I'm sorry, It's Crohns disease.");
case 14: break;
msg.reply("I'm sorry, It's Diabetes."); case 14:
break; msg.reply("I'm sorry, It's Diabetes.");
case 15: break;
msg.reply("I'm sorry, It's Glaucoma."); case 15:
break; msg.reply("I'm sorry, It's Glaucoma.");
case 16: break;
msg.reply("I'm sorry, It's Haemophilia."); case 16:
break; msg.reply("I'm sorry, It's Haemophilia.");
case 17: break;
msg.reply("I'm sorry, It's Hypertension."); case 17:
break; msg.reply("I'm sorry, It's Hypertension.");
case 18: break;
msg.reply("I'm sorry, It's Hypothyroidism."); case 18:
break; msg.reply("I'm sorry, It's Hypothyroidism.");
case 19: break;
msg.reply("I'm sorry, It's Multiple sclerosis."); case 19:
break; msg.reply("I'm sorry, It's Multiple sclerosis.");
case 20: break;
msg.reply("I'm sorry, It's Parkinsons disease."); case 20:
break; msg.reply("I'm sorry, It's Parkinsons disease.");
case 21: break;
msg.reply("I'm sorry, It's Rheumatoid arthritis."); case 21:
break; msg.reply("I'm sorry, It's Rheumatoid arthritis.");
case 22: break;
msg.reply("I'm sorry, It's Schizophrenia."); case 22:
break; msg.reply("I'm sorry, It's Schizophrenia.");
case 23: break;
msg.reply("I'm sorry, It's Systemic lupus erythematosus."); case 23:
break; msg.reply("I'm sorry, It's Systemic lupus erythematosus.");
case 24: break;
msg.reply("I'm sorry, It's Ulcerative colitis."); case 24:
break; msg.reply("I'm sorry, It's Ulcerative colitis.");
case 25: break;
msg.reply("I'm sorry, It's Bipolar Mood Disorder."); case 25:
break; msg.reply("I'm sorry, It's Bipolar Mood Disorder.");
break;
}
} }
} }
@@ -91,4 +93,4 @@ function getRandomInt(min, max) {
min = Math.ceil(min); min = Math.ceil(min);
max = Math.floor(max); max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
} }

View File

@@ -1,18 +1,20 @@
exports.name = "Emote Page Test" module.exports = {
exports.alias = ['emotetest'] name = "Emote Page Test",
exports.helptext = "testing for emote responses" alias =['emotetest'],
exports.helphide = true; helptext = "testing for emote responses",
exports.command = (client, msg) => { helphide = true;,
command = (client, msg) => {
msg.reply ("testing emote thing") msg.reply("testing emote thing")
.then(sent => { .then(sent => {
sent.react('555213405217226776').then( sent.react('555213405217226776').then(
() => message.react('555213429200388116')); () => message.react('555213429200388116'));
const filter = (reaction, user) => user.id === msg.member.user.id const filter = (reaction, user) => user.id === msg.member.user.id
sent.awaitReactions(filter) sent.awaitReactions(filter)
.then(collected => console.log(`Collected ${collected.size} reactions`)) .then(collected => console.log(`Collected ${collected.size} reactions`))
.catch(console.error); .catch(console.error);
}) })
return true; return true;
}
} }

View File

@@ -1,11 +1,13 @@
exports.name = 'Get auto parent' module.exports = {
exports.alias = ['getautoparent'] name = 'Get auto parent',
exports.helptext = 'gets the auto creation channel' alias =['getautoparent'],
exports.helphide = false helptext = 'gets the auto creation channel',
exports.permissions = ['ADMINISTRATOR'] helphide = false,
exports.category = 'admin' permissions =['ADMINISTRATOR'],
exports.command = (client, msg) => { category = 'admin',
client.database.get_setting("autoParent", msg.guild.id).then((r) => { command = (client, msg) => {
msg.reply(`${r} - ${msg.guild.channels.get(r).name}`); client.database.get_setting("autoParent", msg.guild.id).then((r) => {
}); msg.reply(`${r} - ${msg.guild.channels.get(r).name}`);
});
}
} }

View File

@@ -1,12 +1,14 @@
exports.name = 'Get auto voice' module.exports = {
exports.alias = ['getautovoice'] name = 'Get auto voice',
exports.helptext = 'Set the auto-sorting channel' alias =['getautovoice'],
exports.helphide = false helptext = 'Set the auto-sorting channel',
exports.permissions = ['READ_MESSAGES'] helphide = false,
exports.category = 'admin' permissions =['READ_MESSAGES'],
exports.command = (client, msg) => { category = 'admin',
client.database.get_setting("autoVoice", msg.guild.id).then((r) => { command = (client, msg) => {
msg.reply(`${r} - ${msg.guild.channels.get(r).name}`); client.database.get_setting("autoVoice", msg.guild.id).then((r) => {
}); msg.reply(`${r} - ${msg.guild.channels.get(r).name}`);
});
}
} }

View File

@@ -1,91 +1,86 @@
const fs = require('fs') const fs = require('fs')
const Discord = require('discord.js') const Discord = require('discord.js')
exports.name = "Help file" module.exports = {
exports.alias = ['help', '?'] name = "Help file",
exports.helptext = "Runs this help menu" alias =['help', '?'],
exports.permissions = ['VIEW_CHANNEL'] helptext = "Runs this help menu",
exports.args = ['(general)/music/admin'] permissions =['VIEW_CHANNEL'],
exports.command = (client, msg) => { 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")
fs.readdir("./commands/", function (err, items) { var suffix = msg.suffix;
var embed = new Discord.RichEmbed var lookingfor = 0
embed.color = 0x0ca9fe if (msg.suffix.toLowerCase() == "admin") {
//embed.setAuthor("DAdmin", "https://cdn.discordapp.com/avatars/476369946386104330/833d7f2fcae8a31f6c74551c8f703ca8.png", "https://litruv.com") lookingfor = 1
suffix = "admin"
} else if (msg.suffix.toLowerCase() == "music") {
lookingfor = 2
suffix = "music"
} else {
lookingfor = 0;
suffix = "general"
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'
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 + "```" var description = "";
if (i != items.length -1) switch (lookingfor) {
description += "\n"; 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"
} for (var i = 0; i < items.length; i++) {
embed.setDescription(description) 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);
})
}
} }

View File

@@ -1,29 +1,30 @@
var request = require('request'); var request = require('request');
var url = "https://www.reddit.com/r/dadjokes/hot/.json?limit=100"; 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' //var parsed = JSON.parse(response)
exports.alias = ['joke'] var jokenumber = getRandomInt(0, 25);
exports.helptext = 'Fresh dad jokes from reddit.com/r/dadjokes' msg.reply(body.data.children[jokenumber].data.title + " " + body.data.children[jokenumber].data.selftext); // Print the json response
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
}
});
} }
function getRandomInt(min, max) { function getRandomInt(min, max) {
min = Math.ceil(min); min = Math.ceil(min);
max = Math.floor(max); max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
} }

View File

@@ -1,16 +1,18 @@
exports.name = 'Move all' module.exports = {
exports.alias = ['moveall'] name = 'Move all',
exports.helptext = 'Moves all people from one Voice Chat, to the next' alias =['moveall'],
exports.helphide = false helptext = 'Moves all people from one Voice Chat, to the next',
exports.permissions = ['MOVE_MEMBERS'] helphide = false,
exports.args = ['ChannelID', 'ChannelID'] permissions =['MOVE_MEMBERS'],
exports.category = 'admin' args =['ChannelID', 'ChannelID'],
exports.command = (client, msg) => { category = 'admin',
cleaner = msg.cleanContent.replace(/\s\s+/g, ' '); command = (client, msg) => {
chans = cleaner.split(' '); cleaner = msg.cleanContent.replace(/\s\s+/g, ' ');
console.log("From: " + chans[1]); chans = cleaner.split(' ');
msg.guild.channels.get(chans[1]).members.forEach(m => { console.log("From: " + chans[1]);
m.setVoiceChannel(chans[2]); msg.guild.channels.get(chans[1]).members.forEach(m => {
}); m.setVoiceChannel(chans[2]);
});
}
} }

View File

@@ -1,21 +1,23 @@
exports.name = 'Permissions' module.exports = {
exports.alias = ['permissions'] name = 'Permissions',
exports.helptext = 'Check permissions for user' alias =['permissions'],
exports.helphide = false helptext = 'Check permissions for user',
exports.permissions = ['MANAGE_ROLES_OR_PERMISSIONS'] helphide = false,
exports.args = ['@Tag'] permissions =['MANAGE_ROLES_OR_PERMISSIONS'],
exports.category = 'admin' args =['@Tag'],
exports.command = (client, msg) => { category = 'admin',
if(msg.mentions.members.array().length != 1) command = (client, msg) => {
return; if (msg.mentions.members.array().length != 1)
return;
var perms = msg.mentions.members.first().permissions.toArray(true); var perms = msg.mentions.members.first().permissions.toArray(true);
var message = ""; var message = "";
for (var i = 0; i < perms.length; i++) { for (var i = 0; i < perms.length; i++) {
message += perms[i]; message += perms[i];
if (i != perms.length -1) if (i != perms.length - 1)
message += ", "; message += ", ";
}
msg.reply(message);
} }
msg.reply(message);
} }

View File

@@ -1,29 +1,30 @@
var request = require('request'); var request = require('request');
var url = "https://www.reddit.com/r/doggos/hot/.json?limit=100"; var url = "https://www.reddit.com/r/doggos/hot/.json?limit=100";
exports.name = 'Doggo' module.exports = {
exports.alias = ['doggo'] name = 'Doggo',
exports.helptext = 'Inserts good boye from reddit/r/doggos' alias =['doggo'],
exports.helphide = false helptext = 'Inserts good boye from reddit/r/doggos',
exports.permissions = ['READ_MESSAGES'] helphide = false,
exports.category = 'general' permissions =['READ_MESSAGES'],
exports.command = (client, msg) => { category = 'general',
request({ command = (client, msg) => {
url: url, request({
json: true url: url,
}, function (error, response, body) { json: true
if (!error && response.statusCode === 200) { }, function (error, response, body) {
var sent = false; if (!error && response.statusCode === 200) {
while (!sent) { var sent = false;
var jokenumber = getRandomInt(1, 25); while (!sent) {
if (body.data.children[jokenumber].data.url.endsWith(".jpg")) var jokenumber = getRandomInt(1, 25);
{ if (body.data.children[jokenumber].data.url.endsWith(".jpg")) {
msg.channel.send({file:body.data.children[jokenumber].data.url}); msg.channel.send({ file: body.data.children[jokenumber].data.url });
sent = true; sent = true;
}
} }
} }
} });
}); }
} }
function getRandomInt(min, max) { function getRandomInt(min, max) {

View File

@@ -1,29 +1,30 @@
var request = require('request'); var request = require('request');
var url = "https://www.reddit.com/r/cats/hot/.json?limit=100"; var url = "https://www.reddit.com/r/cats/hot/.json?limit=100";
exports.name = 'Kitty' module.exports = {
exports.alias = ['kitty'] name = 'Kitty',
exports.helptext = 'Inserts good boye from reddit/r/cats' alias =['kitty'],
exports.helphide = false helptext = 'Inserts good boye from reddit/r/cats',
exports.permissions = ['READ_MESSAGES'] helphide = false,
exports.category = 'general' permissions =['READ_MESSAGES'],
exports.command = (client, msg) => { category = 'general',
request({ command = (client, msg) => {
url: url, request({
json: true url: url,
}, function (error, response, body) { json: true
if (!error && response.statusCode === 200) { }, function (error, response, body) {
var sent = false; if (!error && response.statusCode === 200) {
while (!sent) { var sent = false;
var jokenumber = getRandomInt(1, 25); while (!sent) {
if (body.data.children[jokenumber].data.url.endsWith(".jpg")) var jokenumber = getRandomInt(1, 25);
{ if (body.data.children[jokenumber].data.url.endsWith(".jpg")) {
msg.channel.send({file:body.data.children[jokenumber].data.url}); msg.channel.send({ file: body.data.children[jokenumber].data.url });
sent = true; sent = true;
}
} }
} }
} });
}); }
} }
function getRandomInt(min, max) { function getRandomInt(min, max) {

View File

@@ -1,29 +1,30 @@
var request = require('request'); var request = require('request');
var url = "https://www.reddit.com/r/lizards/hot/.json?limit=100"; var url = "https://www.reddit.com/r/lizards/hot/.json?limit=100";
exports.name = 'Lizard' module.exports = {
exports.alias = ['lizard'] name = 'Lizard',
exports.helptext = 'Inserts good boye from reddit/r/lizards' alias =['lizard'],
exports.helphide = false helptext = 'Inserts good boye from reddit/r/lizards',
exports.permissions = ['READ_MESSAGES'] helphide = false,
exports.category = 'general' permissions =['READ_MESSAGES'],
exports.command = (client, msg) => { category = 'general',
request({ command = (client, msg) => {
url: url, request({
json: true url: url,
}, function (error, response, body) { json: true
if (!error && response.statusCode === 200) { }, function (error, response, body) {
var sent = false; if (!error && response.statusCode === 200) {
while (!sent) { var sent = false;
var jokenumber = getRandomInt(1, 25); while (!sent) {
if (body.data.children[jokenumber].data.url.endsWith(".jpg")) var jokenumber = getRandomInt(1, 25);
{ if (body.data.children[jokenumber].data.url.endsWith(".jpg")) {
msg.channel.send({file:body.data.children[jokenumber].data.url}); msg.channel.send({ file: body.data.children[jokenumber].data.url });
sent = true; sent = true;
}
} }
} }
} });
}); }
} }
function getRandomInt(min, max) { function getRandomInt(min, max) {

View File

@@ -1,29 +1,30 @@
var request = require('request'); var request = require('request');
var url = "https://www.reddit.com/r/mlem/hot/.json?limit=100"; var url = "https://www.reddit.com/r/mlem/hot/.json?limit=100";
exports.name = 'Mlem' module.exports = {
exports.alias = ['mlem'] name = 'Mlem',
exports.helptext = 'Inserts good boye from reddit/r/mlem' alias =['mlem'],
exports.helphide = false helptext = 'Inserts good boye from reddit/r/mlem',
exports.permissions = ['READ_MESSAGES'] helphide = false,
exports.category = 'general' permissions =['READ_MESSAGES'],
exports.command = (client, msg) => { category = 'general',
request({ command = (client, msg) => {
url: url, request({
json: true url: url,
}, function (error, response, body) { json: true
if (!error && response.statusCode === 200) { }, function (error, response, body) {
var sent = false; if (!error && response.statusCode === 200) {
while (!sent) { var sent = false;
var jokenumber = getRandomInt(1, 25); while (!sent) {
if (body.data.children[jokenumber].data.url.endsWith(".jpg")) var jokenumber = getRandomInt(1, 25);
{ if (body.data.children[jokenumber].data.url.endsWith(".jpg")) {
msg.channel.send({file:body.data.children[jokenumber].data.url}); msg.channel.send({ file: body.data.children[jokenumber].data.url });
sent = true; sent = true;
}
} }
} }
} });
}); }
} }
function getRandomInt(min, max) { function getRandomInt(min, max) {

View File

@@ -1,29 +1,30 @@
var request = require('request'); var request = require('request');
var url = "https://www.reddit.com/r/sloths/hot/.json?limit=100"; var url = "https://www.reddit.com/r/sloths/hot/.json?limit=100";
exports.name = 'Sloth' module.exports = {
exports.alias = ['sloth'] name = 'Sloth',
exports.helptext = 'Inserts good boye from reddit/r/sloths' alias =['sloth'],
exports.helphide = false helptext = 'Inserts good boye from reddit/r/sloths',
exports.permissions = ['READ_MESSAGES'] helphide = false,
exports.category = 'general' permissions =['READ_MESSAGES'],
exports.command = (client, msg) => { category = 'general',
request({ command = (client, msg) => {
url: url, request({
json: true url: url,
}, function (error, response, body) { json: true
if (!error && response.statusCode === 200) { }, function (error, response, body) {
var sent = false; if (!error && response.statusCode === 200) {
while (!sent) { var sent = false;
var jokenumber = getRandomInt(1, 25); while (!sent) {
if (body.data.children[jokenumber].data.url.endsWith(".jpg")) var jokenumber = getRandomInt(1, 25);
{ if (body.data.children[jokenumber].data.url.endsWith(".jpg")) {
msg.channel.send({file:body.data.children[jokenumber].data.url}); msg.channel.send({ file: body.data.children[jokenumber].data.url });
sent = true; sent = true;
}
} }
} }
} });
}); }
} }
function getRandomInt(min, max) { function getRandomInt(min, max) {

View File

@@ -1,18 +1,20 @@
exports.name = 'Restart' module.exports = {
exports.alias = ['restart'] name = 'Restart',
exports.helptext = 'Restart DAdmin' alias =['restart'],
exports.helphide = true helptext = 'Restart DAdmin',
exports.permissions = ['READ_MESSAGES'] helphide = true,
exports.category = 'admin' permissions =['READ_MESSAGES'],
exports.command = (client, msg) => { category = 'admin',
var r = "220772082055774210"; command = (client, msg) => {
if (msg.member.id == r) { var r = "220772082055774210";
msg.react("✅"); if (msg.member.id == r) {
msg.reply("Shutting Down.. 😭"); msg.react("");
setTimeout(function () { msg.reply("Shutting Down.. 😭");
process.exit(22); setTimeout(function () {
}, 1000); process.exit(22);
} else { }, 1000);
msg.react("❌"); } else {
msg.react("❌");
}
} }
} }

View File

@@ -1,10 +1,12 @@
exports.name = 'Set auto parent' module.exports = {
exports.alias = ['setautoparent'] name = 'Set auto parent',
exports.helptext = 'sets the auto creation category' alias =['setautoparent'],
exports.helphide = false helptext = 'sets the auto creation category',
exports.permissions = ['ADMINISTRATOR'] helphide = false,
exports.args = ['VChannelID'] permissions =['ADMINISTRATOR'],
exports.category = 'admin' args =['VChannelID'],
exports.command = (client, msg) => { category = 'admin',
database.set_setting(msg.guild.id, "autoParent", msg.suffix); command = (client, msg) => {
database.set_setting(msg.guild.id, "autoParent", msg.suffix);
}
} }

View File

@@ -1,10 +1,12 @@
exports.name = 'Set auto voice' module.exports = {
exports.alias = ['setautovoice'] name = 'Set auto voice',
exports.helptext = 'Sets the auto-sorting voice channel' alias =['setautovoice'],
exports.helphide = false helptext = 'Sets the auto-sorting voice channel',
exports.permissions = ['ADMINISTRATOR'] helphide = false,
exports.args = ['VChannelID'] permissions =['ADMINISTRATOR'],
exports.category = 'admin' args =['VChannelID'],
exports.command = (client, msg) => { category = 'admin',
client.database.set_setting(msg.guild.id, "autoVoice", msg.suffix); command = (client, msg) => {
client.database.set_setting(msg.guild.id, "autoVoice", msg.suffix);
}
} }

View File

@@ -1,33 +1,28 @@
exports.name = 'Slap' module.exports = {
exports.alias = ['slap'] name = 'Slap',
exports.helptext = 'Slaps users to empty channels and back again' alias =['slap'],
exports.helphide = false helptext = 'Slaps users to empty channels and back again',
exports.permissions = ['MOVE_MEMBERS'] helphide = false,
exports.args = ['@Tag'] permissions =['MOVE_MEMBERS'],
exports.category = 'admin' args =['@Tag'],
exports.command = (client, msg) => { category = 'admin',
client.database.get_setting("autoVoice", msg.guild.id).then((autochan) => { command = (client, msg) => {
var itemsProcessed = 0; client.database.get_setting("autoVoice", msg.guild.id).then((autochan) => {
var cid = msg.mentions.members.first().voiceChannelID; var itemsProcessed = 0
var cid = msg.mentions.members.first().voiceChannelID
msg.guild.channels.filter(isVoice).forEach(element => { msg.guild.channels.filter(c => value.type == "voice").forEach(element => {
itemsProcessed++; itemsProcessed++
if (itemsProcessed <= 8) {
if (itemsProcessed <= 8) { if (element.id != autochan) {
if (element.id != autochan) { if (element.members.array().length == 0)
if (element.members.array().length == 0); msg.mentions.members.first().setVoiceChannel(element.id)
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";
} }

View File

@@ -1,25 +1,23 @@
exports.name = 'Stats for DAdmin' module.exports = {
exports.alias = ['stats'] name = 'Stats for DAdmin',
exports.helptext = 'Metrics on DAdmin, uptime, users, servers' alias =['stats'],
exports.helphide = false helptext = 'Metrics on DAdmin, uptime, users, servers',
exports.permissions = ['READ_MESSAGES'] helphide = false,
exports.category = 'general' permissions =['READ_MESSAGES'],
exports.command = (client, msg) => { category = 'general',
var users = 0; command = (client, msg) => {
for (var i = 0; i < client.guilds.array().length; i++){ var users = 0;
users += client.guilds.array()[i].members.array().length; 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");
} }
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) { function numberEnding(number) {
// TIP: to find current time in milliseconds, use:
// var current_time_milliseconds = new Date().getTime();
function numberEnding (number) {
return (number > 1) ? 's' : ''; return (number > 1) ? 's' : '';
} }
@@ -47,4 +45,3 @@ function millisecondsToStr (milliseconds) {
} }
return 'less than a second'; //'just now' //or other string you like; return 'less than a second'; //'just now' //or other string you like;
} }