Fix All the Crap

This commit is contained in:
Daniel Odendahl Jr
2017-03-25 04:52:59 +00:00
parent ebfbf31787
commit cb4abd7ac4
12 changed files with 42 additions and 59 deletions
+3 -5
View File
@@ -13,10 +13,7 @@ module.exports = class MathGameCommand extends commando.Command {
args: [{
key: 'difficulty',
prompt: 'What difficulty should the math game be? Easy, Medium, Hard, or Extreme?',
type: 'string',
validate: (str) => {
str.toLowerCase() === 'easy' || str.toLowerCase() === 'medium' || str.toLowerCase() === 'hard' || str.toLowerCase() === 'extreme';
}
type: 'string'
}]
});
}
@@ -26,7 +23,8 @@ module.exports = class MathGameCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
}
console.log(`[Command] ${message.content}`);
let level = args.difficulty;
let level = args.difficulty.toLowerCase();
if (level !== 'easy' || level !== 'medium' || level !== 'hard' || level !== 'extreme') return message.channel.send(':x: Error! Please set the difficulty to either easy, medium, hard, or extreme!');
let randomType = ['+', '-', '*'];
randomType = randomType[Math.floor(Math.random() * randomType.length)];
let randomValue;
+2 -4
View File
@@ -15,9 +15,6 @@ module.exports = class RockPaperScissors extends commando.Command {
key: 'choice',
prompt: 'Rock, Paper, or Scissors?',
type: 'string',
validate: (str) => {
str.toLowerCase() === 'rock' || str.toLowerCase() === 'paper' || str.toLowerCase() === 'scissors';
}
}]
});
}
@@ -27,7 +24,7 @@ module.exports = class RockPaperScissors extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
let rps = args.choice;
let rps = args.choice.toLowerCase();
let response = ['Paper', 'Rock', 'Scissors'];
response = response[Math.floor(Math.random() * response.length)];
if (rps.includes("rock")) {
@@ -63,5 +60,6 @@ module.exports = class RockPaperScissors extends commando.Command {
return message.channel.send("Scissors! Aw, it's a tie!");
}
}
else return message.channel.send(':x: Error! Please enter rock, paper, or scissors!');
}
};
+3 -5
View File
@@ -12,10 +12,7 @@ module.exports = class TypingGameCommand extends commando.Command {
args: [{
key: 'difficulty',
prompt: 'What difficulty should the typing game be? Easy, Medium, Hard, or Extreme?',
type: 'string',
validate: (str) => {
str.toLowerCase() === 'easy' || str.toLowerCase() === 'medium' || str.toLowerCase() === 'hard' || str.toLowerCase() === 'extreme';
}
type: 'string'
}]
});
}
@@ -25,7 +22,8 @@ module.exports = class TypingGameCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
}
console.log(`[Command] ${message.content}`);
let level = args.difficulty;
let level = args.difficulty.toLowerCase();
if (level !== 'easy' || level !== 'medium' || level !== 'hard' || level !== 'extreme') return message.channel.send(':x: Error! Please set the difficulty to either easy, medium, hard, or extreme!');
let randomSentence = ['The quick brown fox jumps over the lazy dog.', 'Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.', 'How razorback-jumping frogs can level six piqued gymnasts!', 'Amazingly few discotheques provide jukeboxes.'];
randomSentence = randomSentence[Math.floor(Math.random() * randomSentence.length)];
let time;
+5 -9
View File
@@ -112,17 +112,11 @@ module.exports = class MemeCommand extends commando.Command {
args: [{
key: 'type',
prompt: 'What meme type do you want to use?',
type: 'string',
validate: (str) => {
memecodes[str] || str === 'list';
}
type: 'string'
}, {
key: 'content',
prompt: 'What should the meme content be?',
type: 'string',
validate: (str) => {
str.includes(" | ") && str.match(/^[a-zA-Z0-9|.,!?'-\s]+$/);
}
type: 'string'
}]
});
}
@@ -132,8 +126,10 @@ module.exports = class MemeCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return;
}
console.log(`[Command] ${message.content}`);
let type = args.type;
let type = args.type.toLowerCase();
if (!memecodes[type] || type !== 'list') return message.channel.send(':x: Error! Meme type not found! Use `;meme list` to view a list of meme types.');
let content = args.content;
if (!content.includes(' | ') || !content.match(/^[a-zA-Z0-9|.,!?'-\s]+$/)) return message.channel.send(':x: Error! Invalid content! Split your choices with a " | " or do not use special characters!');
if (type === "list") return message.channel.send("**Type Codes:** tenguy, afraid, older, aag, tried, biw, blb, kermit, bd, ch, cbg, wonka, cb, keanu, dsm, live, ants, doge, alwaysonbeat, ermg, facepalm, fwp, fa, fbf, fry, hipster, icanhas, crazypills, mw, noidea, regret, boat, hagrid, sohappy, captain, inigo, iw, ackbar, happening, joker, ive, ll, morpheus, mb, badchoice, mmm, jetpack, red, mordor, oprah, oag, remembers, philosoraptor, jw, patrick, rollsafe, sad-obama, sad-clinton, sadfrog, sad-bush, sad-biden, sad-boehner, saltbae, sarcasticbear, dwight, sb, ss, sf, dodgson, money, sohot, nice, awesome-awkward, awesome, awkward-awesome, awkward, fetch, success, scc, ski, officespace, interesting, toohigh, bs, center, both, winter, xy, buzz, yodawg, uno, yallgot, bad, elf, chosen");
let memeQuery = content.split(" ").join("-").split("-|-");
let toprow = memeQuery[0].split("?").join("~q");
+3 -1
View File
@@ -27,7 +27,9 @@ module.exports = class ChooseCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
let choices = args.choices.split(' | ');
let choices = args.choices;
if (!choices.includes(' | ')) return message.channel.send(':x: Error! Split your messages with a " | "!');
choices = choices.split(" | ");
choices = choices[Math.floor(Math.random() * choices.length)];
return message.channel.send(`I choose ${choices}!`);
}
+4 -4
View File
@@ -15,10 +15,7 @@ module.exports = class RandomNameGen extends commando.Command {
args: [{
key: 'gender',
prompt: 'Which gender do you want to generate a name for?',
type: 'string',
validate: (str) => {
str.toLowerCase() === 'male' || str.toLowerCase() === 'female';
}
type: 'string'
}]
});
}
@@ -41,5 +38,8 @@ module.exports = class RandomNameGen extends commando.Command {
else if (gender === "female") {
return message.channel.send(`${randomFirstFemale} ${randomLast}`);
}
else {
return message.channel.send(':x: Error! Please set either male or female!');
}
}
};
+2 -4
View File
@@ -16,10 +16,7 @@ module.exports = class DiscrimCommand extends commando.Command {
args: [{
key: 'discrim',
prompt: 'Which discriminator would you like to search for?',
type: 'string',
validate: (str) => {
str.match(/^[0-9]+$/) && str.length === 4;
}
type: 'string'
}]
});
}
@@ -30,6 +27,7 @@ module.exports = class DiscrimCommand extends commando.Command {
}
console.log(`[Command] ${message.content}`);
let userToSearch = args.discrim;
if (!userToSearch.match(/^[0-9]+$/) || userToSearch.length !== 4) return message.channel.send(':x: Error! Invalid Discriminator!');
let users = await this.client.users.filter(u => u.discriminator === userToSearch).map(u => u.username).sort();
const embed = new Discord.RichEmbed()
.setTitle(`${users.length} Users with the discriminator: ${userToSearch}`)
+2 -4
View File
@@ -16,10 +16,7 @@ module.exports = class PokedexCommand extends commando.Command {
args: [{
key: 'pokemon',
prompt: 'What Pokémon would you like to get info on?',
type: 'string',
validate: (str) => {
pokedex.name[str.toLowerCase()];
}
type: 'string'
}]
});
}
@@ -30,6 +27,7 @@ module.exports = class PokedexCommand extends commando.Command {
}
console.log(`[Command] ${message.content}`);
let pokemon = args.pokemon;
if (!pokedex.name[pokemon.toLowerCase()]) return message.channel.send(':x: Error! This Pokémon is either not valid, or is not yet implemented!');
const embed = new Discord.RichEmbed()
.setTitle('Information')
.setAuthor(`#${pokedex.index[pokemon]} ${pokedex.name[pokemon]}`, `http://www.serebii.net/pokedex-sm/icon/${pokedex.index[pokemon]}.png`)
+2 -4
View File
@@ -15,10 +15,7 @@ module.exports = class MorseCommand extends commando.Command {
args: [{
key: 'method',
prompt: 'Would you like to encode or decode the text?',
type: 'string',
validate: (str) => {
str.toLowerCase() === 'encode' || str.toLowerCase() === 'decode';
}
type: 'string'
}, {
key: 'text',
prompt: 'What text would you like to convert to morse?',
@@ -33,6 +30,7 @@ module.exports = class MorseCommand extends commando.Command {
}
console.log(`[Command] ${message.content}`);
let methodToUse = args.method;
if (methodToUse.toLowerCase() !== 'encode' || methodToUse.toLowerCase() !== 'decode') return message.channel.send(':x: Error! Please set either encode or decode!');
let toMorse = args.text;
if (methodToUse === 'encode') return message.channel.send(morse.encode(toMorse)).catch(error => message.channel.send(':x: Error! Something went wrong! Perhaps you entered incorrect text?'));
if (methodToUse === 'decode') return message.channel.send(morse.decode(toMorse)).catch(error => message.channel.send(':x: Error! Something went wrong! Perhaps you entered incorrect text?'));
+2 -4
View File
@@ -15,10 +15,7 @@ module.exports = class RomajiCommand extends commando.Command {
args: [{
key: 'kana',
prompt: 'What kana would you like to convert to romaji?',
type: 'string',
validate: (str) => {
hepburn.containsKana(str);
}
type: 'string'
}]
});
}
@@ -29,6 +26,7 @@ module.exports = class RomajiCommand extends commando.Command {
}
console.log(`[Command] ${message.content}`);
let romajify = args.kana;
if (!hepburn.containsKana(romajify)) return message.channel.send(':x: Error! Message contains no Katakana or Hiragana!');
let romajified = hepburn.fromKana(romajify);
if (romajified.length > 1950) return message.channel.send(":x: Error! Your message is too long!");
return message.channel.send(romajified);
+2 -4
View File
@@ -120,10 +120,7 @@ module.exports = class TranslateCommand extends commando.Command {
args: [{
key: 'to',
prompt: 'What language would you like to translate to?',
type: 'string',
validate: (str) => {
languages[str] || str.toLowerCase() === 'list';
}
type: 'string'
}, {
key: 'text',
prompt: 'What text would you like to translate?',
@@ -138,6 +135,7 @@ module.exports = class TranslateCommand extends commando.Command {
}
console.log(`[Command] ${message.content}`);
let languageto = args.to;
if (!languages[languageto] || languageto.toLowerCase() !== 'list') return message.channel.send(':x: Error! Translation type is not valid!');
let thingToTranslate = args.text;
if (languageto === "list") return 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'");
if (thingToTranslate.length > 200) return message.channel.send(":x: Error! Please keep translations below 200 characters!");
+12 -11
View File
@@ -38,19 +38,20 @@ client.registry
})
.registerCommandsIn(path.join(__dirname, 'commands'));
client.on('message', message => {
client.on('message', (message) => {
if (message.author.bot) return;
if (message.channel.type === 'dm') return;
if (!message.content.startsWith(`<@${client.user.id}>`)) {
if (message.guild.id !== config.server || message.guild.id !== config.personalServer || message.author.id !== config.owner) return;
if (clevusers.allowed[message.author.id]) {
let cleverMessage = message.content.replace(`<@${client.user.id}>`, "");
console.log(`[Cleverbot] ${cleverMessage}`);
message.channel.startTyping();
cleverbot.write(cleverMessage, function(response) {
message.reply(response.output);
message.channel.stopTyping();
});
if (message.content.startsWith(`<@${client.user.id}>`)) {
if (message.guild.id === config.server || message.guild.id === config.personalServer || message.author.id === config.owner) {
if (message.author.id === clevusers.allowed[message.author.id]) {
let cleverMessage = message.content.replace(`<@${client.user.id}>`, "");
console.log(`[Cleverbot] ${cleverMessage}`);
message.channel.startTyping();
cleverbot.write(cleverMessage, function(response) {
message.reply(response.output);
message.channel.stopTyping();
});
}
}
}
});