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 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.");
msg.reply("That anagram is too long. Max 9 Letters.")
return;
}
request({
url: url + msg.suffix,
json: true
}, function (error, response, body) {
}, (error, response, body) => {
if (!error && response.statusCode === 200) {
var replystring = "";
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
replystring += body.best[i] + ', '
msg.reply(replystring.substr(0, replystring.length - 2))
}
});
}
}

View File

@@ -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) => {
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);
}
}

View File

@@ -1,10 +1,11 @@
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) => {
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;
@@ -14,3 +15,4 @@ exports.command = (client, msg) => {
return server.guildID == msg.guild.id;
})[0].prefix = msg.suffix;
}
}

View File

@@ -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) => {
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);
}
}

View File

@@ -1,10 +1,11 @@
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) => {
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.");
@@ -86,6 +87,7 @@ exports.command = (client, msg) => {
break;
}
}
}
function getRandomInt(min, max) {
min = Math.ceil(min);

View File

@@ -1,8 +1,9 @@
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 => {
@@ -16,3 +17,4 @@ exports.command = (client, msg) => {
})
return true;
}
}

View File

@@ -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) => {
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}`);
});
}
}

View File

@@ -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) => {
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}`);
});
}
}

View File

@@ -1,14 +1,13 @@
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) => {
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
@@ -50,14 +49,9 @@ exports.command = (client, msg) => {
continue;
if (reqcommand.category == undefined)
reqcommand.category = 'general'
if (reqcommand.category != suffix)
continue;
description += "**" + reqcommand.name + "** - *" + reqcommand.helptext + "* \n "
args = "";
@@ -89,3 +83,4 @@ exports.command = (client, msg) => {
})
}
}

View File

@@ -1,14 +1,14 @@
var request = require('request');
var url = "https://www.reddit.com/r/dadjokes/hot/.json?limit=100";
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) => {
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
@@ -21,6 +21,7 @@ exports.command = (client, msg) => {
}
});
}
}
function getRandomInt(min, max) {
min = Math.ceil(min);

View File

@@ -1,11 +1,12 @@
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) => {
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]);
@@ -14,3 +15,4 @@ exports.command = (client, msg) => {
});
}
}

View File

@@ -1,11 +1,12 @@
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) => {
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;
@@ -19,3 +20,4 @@ exports.command = (client, msg) => {
}
msg.reply(message);
}
}

View File

@@ -1,13 +1,14 @@
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) => {
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
@@ -16,8 +17,7 @@ exports.command = (client, msg) => {
var sent = false;
while (!sent) {
var jokenumber = getRandomInt(1, 25);
if (body.data.children[jokenumber].data.url.endsWith(".jpg"))
{
if (body.data.children[jokenumber].data.url.endsWith(".jpg")) {
msg.channel.send({ file: body.data.children[jokenumber].data.url });
sent = true;
}
@@ -25,6 +25,7 @@ exports.command = (client, msg) => {
}
});
}
}
function getRandomInt(min, max) {
min = Math.ceil(min);

View File

@@ -1,13 +1,14 @@
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) => {
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
@@ -16,8 +17,7 @@ exports.command = (client, msg) => {
var sent = false;
while (!sent) {
var jokenumber = getRandomInt(1, 25);
if (body.data.children[jokenumber].data.url.endsWith(".jpg"))
{
if (body.data.children[jokenumber].data.url.endsWith(".jpg")) {
msg.channel.send({ file: body.data.children[jokenumber].data.url });
sent = true;
}
@@ -25,6 +25,7 @@ exports.command = (client, msg) => {
}
});
}
}
function getRandomInt(min, max) {
min = Math.ceil(min);

View File

@@ -1,13 +1,14 @@
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) => {
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
@@ -16,8 +17,7 @@ exports.command = (client, msg) => {
var sent = false;
while (!sent) {
var jokenumber = getRandomInt(1, 25);
if (body.data.children[jokenumber].data.url.endsWith(".jpg"))
{
if (body.data.children[jokenumber].data.url.endsWith(".jpg")) {
msg.channel.send({ file: body.data.children[jokenumber].data.url });
sent = true;
}
@@ -25,6 +25,7 @@ exports.command = (client, msg) => {
}
});
}
}
function getRandomInt(min, max) {
min = Math.ceil(min);

View File

@@ -1,13 +1,14 @@
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) => {
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
@@ -16,8 +17,7 @@ exports.command = (client, msg) => {
var sent = false;
while (!sent) {
var jokenumber = getRandomInt(1, 25);
if (body.data.children[jokenumber].data.url.endsWith(".jpg"))
{
if (body.data.children[jokenumber].data.url.endsWith(".jpg")) {
msg.channel.send({ file: body.data.children[jokenumber].data.url });
sent = true;
}
@@ -25,6 +25,7 @@ exports.command = (client, msg) => {
}
});
}
}
function getRandomInt(min, max) {
min = Math.ceil(min);

View File

@@ -1,13 +1,14 @@
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) => {
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
@@ -16,8 +17,7 @@ exports.command = (client, msg) => {
var sent = false;
while (!sent) {
var jokenumber = getRandomInt(1, 25);
if (body.data.children[jokenumber].data.url.endsWith(".jpg"))
{
if (body.data.children[jokenumber].data.url.endsWith(".jpg")) {
msg.channel.send({ file: body.data.children[jokenumber].data.url });
sent = true;
}
@@ -25,6 +25,7 @@ exports.command = (client, msg) => {
}
});
}
}
function getRandomInt(min, max) {
min = Math.ceil(min);

View File

@@ -1,10 +1,11 @@
exports.name = 'Restart'
exports.alias = ['restart']
exports.helptext = 'Restart DAdmin'
exports.helphide = true
exports.permissions = ['READ_MESSAGES']
exports.category = 'admin'
exports.command = (client, msg) => {
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("✅");
@@ -16,3 +17,4 @@ exports.command = (client, msg) => {
msg.react("❌");
}
}
}

View File

@@ -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) => {
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);
}
}

View File

@@ -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) => {
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);
}
}

View File

@@ -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) => {
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(isVoice).forEach(element => {
itemsProcessed++;
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 (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";
}

View File

@@ -1,23 +1,21 @@
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) => {
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) {
// TIP: to find current time in milliseconds, use:
// var current_time_milliseconds = new Date().getTime();
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;
}