Huge Modification to Code

This commit is contained in:
Daniel Odendahl Jr
2017-03-21 19:20:47 +00:00
parent 65bf037068
commit d49fe32bf6
100 changed files with 1541 additions and 2049 deletions
+5 -8
View File
@@ -1,10 +1,10 @@
const commando = require('discord.js-commando');
const stringToBinary = require('string-to-binary');
class BinaryCommand extends commando.Command {
module.exports = class BinaryCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'binary',
name: 'binary',
group: 'textedit',
memberName: 'binary',
description: 'Converts text to binary. (;binary This text)',
@@ -12,15 +12,12 @@ class BinaryCommand extends commando.Command {
});
}
async run(message, args) {
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log("[Command] " + message.content);
let turnToBinary = message.content.split(" ").slice(1).join(" ");
message.channel.send(stringToBinary(turnToBinary)).catch(error => message.channel.send(':x: Error! Translation is too long, or nothing was entered!'));
}
}
module.exports = BinaryCommand;
};
+5 -8
View File
@@ -1,10 +1,10 @@
const commando = require('discord.js-commando');
const cowsay = require('cowsay');
class CowsayCommand extends commando.Command {
module.exports = class CowsayCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'cowsay',
name: 'cowsay',
group: 'textedit',
memberName: 'cowsay',
description: 'Converts text to cowsay. (;cowsay This text)',
@@ -12,10 +12,9 @@ class CowsayCommand extends commando.Command {
});
}
async run(message, args) {
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log("[Command] " + message.content);
if(message.content.split(" ").slice(1).join(" ") === "") {
@@ -31,6 +30,4 @@ class CowsayCommand extends commando.Command {
});
}
}
}
module.exports = CowsayCommand;
};
+8 -12
View File
@@ -1,10 +1,10 @@
const commando = require('discord.js-commando');
const Discord = require('discord.js');
class EmbedCommand extends commando.Command {
module.exports = class EmbedCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'embed',
name: 'embed',
group: 'textedit',
memberName: 'embed',
description: 'Sends a message in an embed. (;embed This is an example.)',
@@ -12,27 +12,23 @@ class EmbedCommand extends commando.Command {
});
}
async run(message, args) {
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
}
console.log("[Command] " + message.content);
let embedmessage = message.content.split(" ").slice(1).join(" ");
if(embedmessage === "") {
let embedMessage = message.content.split(" ").slice(1).join(" ");
if(embedMessage === "") {
message.channel.send(":x: Error! Nothing to embed!");
} else {
const embed = new Discord.RichEmbed()
.setAuthor(message.author.username, message.author.avatarURL)
.setColor(0x00AE86)
.setTimestamp()
.setDescription(embedmessage);
.setDescription(embedMessage);
message.channel.sendEmbed(embed).catch(console.error);
if (message.channel.type === 'dm') return;
message.delete();
}
}
}
module.exports = EmbedCommand;
};
+8 -8
View File
@@ -1,10 +1,13 @@
const commando = require('discord.js-commando');
const morse = require('morse');
class MorseCommand extends commando.Command {
module.exports = class MorseCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'morse',
name: 'morse',
aliases: [
'morsecode'
],
group: 'textedit',
memberName: 'morse',
description: 'Translates text to and from morse code. (;morse encode This is Morse Code.)',
@@ -12,10 +15,9 @@ class MorseCommand extends commando.Command {
});
}
async run(message, args) {
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log("[Command] " + message.content);
let [methodToUse] = message.content.toLowerCase().split(" ").slice(1);
@@ -30,6 +32,4 @@ class MorseCommand extends commando.Command {
message.channel.send(":x: Error! Method not set/not correct! Use either encode or decode.");
}
}
}
module.exports = MorseCommand;
};
+12 -11
View File
@@ -1,10 +1,14 @@
const commando = require('discord.js-commando');
const pirateSpeak = require('pirate-speak');
class PirateCommand extends commando.Command {
module.exports = class PirateCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'pirate',
name: 'pirate',
aliases: [
'piratespeak',
'yarr'
],
group: 'textedit',
memberName: 'pirate',
description: 'Talk like a pirate! (;pirate This is being said like a pirate!)',
@@ -12,15 +16,14 @@ class PirateCommand extends commando.Command {
});
}
async run(message, args) {
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log("[Command] " + message.content);
let messagecontent = message.content.split(" ").slice(1).join(" ");
let pirate = pirateSpeak.translate(messagecontent);
if(messagecontent === "") {
let turnToPirate = message.content.split(" ").slice(1).join(" ");
let pirate = pirateSpeak.translate(turnToPirate);
if(turnToPirate === "") {
message.channel.send(":x: Error! Nothing to translate!");
} else {
if(pirate.length > 1950) {
@@ -30,6 +33,4 @@ class PirateCommand extends commando.Command {
}
}
}
}
module.exports = PirateCommand;
};
+8 -14
View File
@@ -1,9 +1,9 @@
const commando = require('discord.js-commando');
class ReverseCommand extends commando.Command {
module.exports = class ReverseCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'reverse',
name: 'reverse',
group: 'textedit',
memberName: 'reverse',
description: 'Reverses text (;reverse This text please)',
@@ -11,23 +11,17 @@ class ReverseCommand extends commando.Command {
});
}
async run(message, args) {
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log("[Command] " + message.content);
function reverseString(str) {
return str.split("").reverse().join("");
}
let messagecontent = message.content.split(" ").slice(1).join(" ");
if(messagecontent === "") {
let stringToReverse = message.content.split(" ").slice(1).join(" ");
if(stringToReverse === "") {
message.channel.send(":x: Error! Nothing to reverse!");
} else {
let reversed = reverseString(messagecontent);
let reversed = stringToReverse.split("").reverse().join("");
message.channel.send(reversed);
}
}
}
module.exports = ReverseCommand;
};
+16 -19
View File
@@ -1,11 +1,14 @@
const commando = require('discord.js-commando');
const request = require('request-promise');
const request = require('superagent');
const config = require('../../config.json');
class RinSayCommand extends commando.Command {
module.exports = class RinSayCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'rin',
name: 'rin',
aliases: [
'rinsay'
],
group: 'textedit',
memberName: 'rin',
description: "Posts a message to the Rin webhook in Heroes of Dreamland. (;rin Hey guys!)",
@@ -16,28 +19,22 @@ class RinSayCommand extends commando.Command {
return this.client.isOwner(msg.author);
}
async run(message, args) {
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log("[Command] " + message.content);
let rinContent = message.content.split(" ").slice(1).join(" ");
const sendPOST = {
method: 'POST',
uri: config.webhook,
body: {
content: rinContent
},
json: true
}
request(sendPOST).then(function (parsedBody) {
if(message.channel.type === 'dm') return;
request
.post(config.webhook)
.send({ content: rinContent })
.then(function (parsedBody) {
message.channel.send('Message sent to the Rin Webhook!');
if(message.content.type === 'dm') return;
message.delete();
}).catch(function (err) {
message.channel.send(':x: Error! Message failed to send! Check the logs for details.');
console.log(err);
});
}
}
module.exports = RinSayCommand;
};
+8 -8
View File
@@ -1,10 +1,13 @@
const commando = require('discord.js-commando');
const hepburn = require('hepburn');
class RomajiCommand extends commando.Command {
module.exports = class RomajiCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'romaji',
name: 'romaji',
aliases: [
'romajify'
],
group: 'textedit',
memberName: 'romaji',
description: 'Convert Hiragana and Katakana to Romaji (;romaji ひらがな)',
@@ -12,10 +15,9 @@ class RomajiCommand extends commando.Command {
});
}
async run(message, args) {
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log("[Command] " + message.content);
let romajify = message.content.split(" ").slice(1).join(" ");
@@ -30,6 +32,4 @@ class RomajiCommand extends commando.Command {
message.channel.send(":x: Error! Message contains no Kana!\n:notepad_spiral: Note: You cannot use this command on Kanji!");
}
}
}
module.exports = RomajiCommand;
};
+13 -11
View File
@@ -1,9 +1,14 @@
const commando = require('discord.js-commando');
class SayCommand extends commando.Command {
module.exports = class SayCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'say',
name: 'say',
aliases: [
'copy',
'repeat',
'parrot'
],
group: 'textedit',
memberName: 'say',
description: 'Make XiaoBot say what you wish. (;say I can talk!)',
@@ -11,21 +16,18 @@ class SayCommand extends commando.Command {
});
}
async run(message, args) {
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log("[Command] " + message.content);
let Copycat = message.content.split(" ").slice(1).join(" ");
if(Copycat === "") {
let copycat = message.content.split(" ").slice(1).join(" ");
if(copycat === "") {
message.channel.send(":x: Error! Nothing to say!");
} else {
message.channel.send(Copycat);
message.channel.send(copycat);
if (message.channel.type === 'dm') return;
message.delete();
}
}
}
module.exports = SayCommand;
};
+13 -16
View File
@@ -1,9 +1,9 @@
const commando = require('discord.js-commando');
class ShuffleCommand extends commando.Command {
module.exports = class ShuffleCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'shuffle',
name: 'shuffle',
group: 'textedit',
memberName: 'shuffle',
description: 'Shuffles text (;shuffle This Text)',
@@ -11,30 +11,27 @@ class ShuffleCommand extends commando.Command {
});
}
async run(message, args) {
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log("[Command] " + message.content);
String.prototype.shuffle = function () {
var a = this.split(""),
let a = this.split(""),
n = a.length;
for(var i = n - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var tmp = a[i];
for(let i = n - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1));
let tmp = a[i];
a[i] = a[j];
a[j] = tmp;
}
return a.join("");
}
let shuffled = message.content.split(" ").slice(1).join(" ");
if(shuffled === '') {
};
let thingToShuffle = message.content.split(" ").slice(1).join(" ");
if(thingToShuffle === '') {
message.channel.send(":x: Error! Nothing to shuffle!");
} else {
message.channel.send(shuffled.shuffle());
message.channel.send(thingToShuffle.shuffle());
}
}
}
module.exports = ShuffleCommand;
};
+13 -17
View File
@@ -3,51 +3,47 @@ const Discord = require('discord.js');
const translate = require('google-translate-api');
const languages = require('./languages.json');
class TranslateCommand extends commando.Command {
module.exports = class TranslateCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'translate',
name: 'translate',
group: 'textedit',
memberName: 'translate',
description: 'Translates text to a given language. (;translate ja Give me the money!) (;translate list to see avaliable language codes!)',
description: 'Translates text to a given language. (;translate ja Give me the money!)',
examples: [';translate ja Give me the the money!', ';translate list']
});
}
async run(message, args) {
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
}
console.log("[Command] " + message.content);
let [languageto] = message.content.toLowerCase().split(" ").slice(1);
let messagecontent = message.content.split(" ").slice(2).join(" ");
let thingToTranslate = message.content.split(" ").slice(2).join(" ");
if(languageto === "list") {
message.channel.send("af': 'Afrikaans\nsq': 'Albanian'\n'ar': 'Arabic\nhy': 'Armenian\naz': 'Azerbaijani\neu': 'Basque\nbe': 'Belarusian\nbn': 'Bengali\nbs': 'Bosnian\nbg': 'Bulgarian\nca': 'Catalan\nceb': 'Cebuano\nny': 'Chichewa\nzh-cn': 'Chinese Simplified\nzh-tw': 'Chinese Traditional\nco': 'Corsican\nhr': 'Croatian\ncs': 'Czech\nda': 'Danish\nnl': 'Dutch\nen': 'English\neo': 'Esperanto\net': 'Estonian\ntl': 'Filipino\nfi': 'Finnish\nfr': 'French\nfy': 'Frisian\ngl': 'Galician\nka': 'Georgian\nde': 'German\nel': 'Greek\ngu': 'Gujarati\nht': 'Haitian Creole\nha': 'Hausa\nhaw': 'Hawaiian\niw': 'Hebrew\nhi': 'Hindi\nhmn': 'Hmong\nhu': 'Hungarian\nis': 'Icelandic\nig': 'Igbo\nid': 'Indonesian\nga': 'Irish\nit': 'Italian\nja': 'Japanese\njw': 'Javanese\nkn': 'Kannada\nkk': 'Kazakh\nkm': 'Khmer\nko': 'Korean\nku': 'Kurdish (Kurmanji)\nky': 'Kyrgyz\nlo': 'Lao\nla': 'Latin\nlv': 'Latvian\nlt': 'Lithuanian\nlb': 'Luxembourgish\nmk': 'Macedonian\nmg': 'Malagasy\nms': 'Malay\nml': 'Malayalam\nmt': 'Maltese\nmi': 'Maori\nmr': 'Marathi\nmn': 'Mongolian\nmy': 'Myanmar (Burmese)\nne': 'Nepali\nno': 'Norwegian\nps': 'Pashto\nfa': 'Persian\npl': 'Polish\npt': 'Portuguese\nma': 'Punjabi\nro': 'Romanian\nru': 'Russian\nsm': 'Samoan\ngd': 'Scots Gaelic\nsr': 'Serbian\nst': 'Sesotho\nsn': 'Shona\nsd': 'Sindhi\nsi': 'Sinhala\nsk': 'Slovak\nsl': 'Slovenian\nso': 'Somali\nes': 'Spanish\nsu': 'Sudanese\nsw': 'Swahili\nsv': 'Swedish\ntg': 'Tajik\nta': 'Tamil\nte': 'Telugu\nth': 'Thai\ntr': 'Turkish\nuk': 'Ukrainian\nur': 'Urdu\nuz': 'Uzbek\nvi': 'Vietnamese\ncy': 'Welsh\nxh': 'Xhosa\nyi': 'Yiddish\nyo': 'Yoruba\nzu': 'Zulu'");
} else if(languages.entries[languageto]) {
if(messagecontent === "") {
if(thingToTranslate === "") {
message.channel.send(":x: Error! Nothing to translate!");
} else if(messagecontent.length > 200) {
} else if(thingToTranslate.length > 200) {
message.channel.send(":x: Error! Please keep translations below 200 characters!");
} else {
translate(messagecontent, {to: languageto}).then(res => {
translate(thingToTranslate, {to: languageto}).then(res => {
let languagefrom = res.from.language.iso.toLowerCase();
const embed = new Discord.RichEmbed()
.setColor(0x00AE86)
.addField('Input (From: ' + languages.entries[languagefrom] + '):',
messagecontent)
thingToTranslate)
.addField('Translation (To: ' + languages.entries[languageto] + '):',
res.text);
message.channel.sendEmbed(embed).catch(console.error);
}).catch(err => {
message.channel.send(":x: Error!");
message.channel.send(":x: Error! Something went wrong!");
});
}
} else {
message.channel.send(":x: Error! Language not found!");
message.channel.send(":x: Error! Language not found! Use `;translate list` to view a list of translate codes!");
}
}
}
module.exports = TranslateCommand;
};
+14 -25
View File
@@ -1,11 +1,11 @@
const commando = require('discord.js-commando');
const request = require('request-promise');
const request = require('superagent');
const config = require('../../config.json');
class YodaCommand extends commando.Command {
module.exports = class YodaCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'yoda',
name: 'yoda',
group: 'textedit',
memberName: 'yoda',
description: 'Converts text to Yoda Speak. (;yoda This is Yoda.)',
@@ -13,39 +13,28 @@ class YodaCommand extends commando.Command {
});
}
async run(message, args) {
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log("[Command] " + message.content);
let yodaspeak = message.content.split(" ").slice(1).join(" ");
if(yodaspeak === "") {
let turnToYoda = message.content.split(" ").slice(1).join(" ");
if(turnToYoda === "") {
message.channel.send(':x: Error! Nothing to translate!');
} else {
const options = {
method: 'GET',
uri: 'https://yoda.p.mashape.com/yoda',
qs: {
sentence: yodaspeak
},
headers: {
'X-Mashape-Key': config.mashapekey,
'Accept': "text/plain"
},
json: true
}
request(options).then(function (response) {
request
.get('https://yoda.p.mashape.com/yoda')
.set({ 'X-Mashape-Key': config.mashapekey, 'Accept': 'text/plain' })
.query({ sentence: turnToYoda })
.then(function (response) {
if(response === undefined) {
message.channel.send(':x: Error! Something went wrong! Keep it simple to avoid this error.');
} else {
message.channel.send(response).catch(error => message.channel.send(':x: Error! Something went wrong! Keep it simple to avoid this error.'));
message.channel.send(response.body).catch(error => message.channel.send(':x: Error! Something went wrong! Keep it simple to avoid this error.'));
}
}).catch(function (err) {
message.channel.send(":x: Error! Unknown Error. Try again later!");
});
}
}
}
module.exports = YodaCommand;
};
+5 -8
View File
@@ -1,10 +1,10 @@
const commando = require('discord.js-commando');
const zalgo = require('zalgolize');
class ZalgoCommand extends commando.Command {
module.exports = class ZalgoCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'zalgo',
name: 'zalgo',
group: 'textedit',
memberName: 'zalgo',
description: 'Zalgoizes Text (;zalgo This Text)',
@@ -12,10 +12,9 @@ class ZalgoCommand extends commando.Command {
});
}
async run(message, args) {
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log("[Command] " + message.content);
let zalgoified = zalgo(message.content.split(" ").slice(1).join(" "));
@@ -27,6 +26,4 @@ class ZalgoCommand extends commando.Command {
message.channel.send(zalgoified);
}
}
}
module.exports = ZalgoCommand;
};