args and more

This commit is contained in:
Daniel Odendahl Jr
2017-03-25 04:16:27 +00:00
parent 8dd6ec1f9b
commit e2a4a92990
82 changed files with 1089 additions and 1021 deletions
-27
View File
@@ -1,27 +0,0 @@
const commando = require('discord.js-commando');
module.exports = class LotteryCommand extends commando.Command {
constructor(Client) {
super(Client, {
name: 'lottery',
group: 'random',
memberName: 'lottery',
description: '1 in 100 Chance of Winning. Winners get... The feeling of winning? (;lottery)',
examples: [';lottery']
});
}
run(message) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
let lotteryNumber = ['Winner'][Math.floor(Math.random() * 100)];
if (lotteryNumber === "Winner") {
return message.channel.send(`Wow ${message.author.username}! You actually won! Great job!`);
}
else {
return message.channel.send(`Nope, sorry ${message.author.username}, you lost.`);
}
}
};
-64
View File
@@ -1,64 +0,0 @@
const commando = require('discord.js-commando');
const Discord = require('discord.js');
const math = require('mathjs');
module.exports = class MathGameCommand extends commando.Command {
constructor(Client) {
super(Client, {
name: 'mathgame',
group: 'random',
memberName: 'mathgame',
description: 'See how fast you can answer a math problem in a given time limit. (;mathgame easy)',
examples: [';mathgame easy', ';mathgame medium', ';mathgame hard', ';mathgame extreme']
});
}
async run(message) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
}
console.log(`[Command] ${message.content}`);
let [level] = message.content.toLowerCase().split(" ").slice(1);
let randomType = ['+', '-', '*'];
randomType = randomType[Math.floor(Math.random() * randomType.length)];
let randomValue;
switch (level) {
case "easy":
randomValue = 10;
break;
case "medium":
randomValue = 50;
break;
case "hard":
randomValue = 100;
break;
case "extreme":
randomValue = 1000;
break;
}
let randomValue1 = Math.floor(Math.random() * randomValue) + 1;
let randomValue2 = Math.floor(Math.random() * randomValue) + 1;
let randomExpression = randomValue1 + randomType + randomValue2;
let solved = math.eval(randomExpression);
if (!randomValue) {
return message.channel.send(':x: Error! No difficulty set! (Choose Easy, Medium, Hard, or Extreme)');
}
else {
const embed = new Discord.RichEmbed()
.setTitle('You have **ten** seconds to answer:')
.setDescription(randomExpression);
let embedMsg = await message.channel.sendEmbed(embed);
try {
let collected = await message.channel.awaitMessages(response => response.content === solved.toString() && response.author.id === message.author.id, {
max: 1,
time: 10000,
errors: ['time'],
});
return message.channel.send(`Good Job! You won! ${solved} is the correct answer!`);
}
catch (err) {
return message.channel.send(`Aw... Too bad, try again next time!\nThe correct answer is: ${solved}`);
}
}
}
};
-51
View File
@@ -1,51 +0,0 @@
const commando = require('discord.js-commando');
const Discord = require('discord.js');
const request = require('superagent');
module.exports = class QuizCommand extends commando.Command {
constructor(Client) {
super(Client, {
name: 'quiz',
aliases: [
'jeopardy'
],
group: 'random',
memberName: 'quiz',
description: 'Answer a quiz question. (;quiz)',
examples: [';quiz']
});
}
async run(message) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
}
console.log("[Command] " + message.content);
try {
let response = await request
.get('http://jservice.io/api/random')
.query({
count: 1
});
let answer = response.body[0].answer.toLowerCase().split("<i>").join("").split("</i>").join("");
const embed = new Discord.RichEmbed()
.setTitle('You have **fifteen** seconds to answer this question:')
.setDescription(`**Category: ${response.body[0].category.title}**\n${response.body[0].question}`);
let embedMsg = await message.channel.sendEmbed(embed);
try {
let collected = await message.channel.awaitMessages(res => res.content.toLowerCase() === answer && res.author.id === message.author.id, {
max: 1,
time: 15000,
errors: ['time']
});
return message.channel.send(`Good Job! You won! ${answer} is the correct answer!`);
}
catch (err) {
return message.channel.send(`Aw... Too bad, try again next time!\nThe Correct Answer was: ${answer}`);
}
}
catch (err) {
return message.channel.send(":x: Error! Something went wrong!");
}
}
};
+8 -3
View File
@@ -12,16 +12,21 @@ module.exports = class RemindCommand extends commando.Command {
group: 'random',
memberName: 'remind',
description: 'Reminds you of something at a certain time. (;remind Eat Food tomorrow)',
examples: [';remind Eat Food tomorrow']
examples: [';remind Eat Food tomorrow'],
args: [{
key: 'remind',
prompt: 'What should I remind you of?',
type: 'string'
}]
});
}
async run(message) {
async run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
let remindMe = message.content.split(" ").slice(1).join(" ");
let remindMe = args.remind;
try {
let remindTime = sherlock.parse(remindMe);
let time = remindTime.startDate.getTime() - Date.now();
+26 -49
View File
@@ -12,61 +12,38 @@ module.exports = class SoundBoardCommand extends commando.Command {
group: 'random',
memberName: 'soundboard',
description: 'Plays a sound in your voice channel. (;soundboard cat)',
examples: [';soundboard cat']
examples: [';soundboard cat'],
guildOnly: true,
args: [{
key: 'sound',
prompt: 'What sound do you want me to play?',
type: 'string'
}]
});
}
async run(message) {
async run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'CONNECT', 'SPEAK', 'ADD_REACTIONS'])) return;
}
console.log(`[Command] ${message.content}`);
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['CONNECT', 'SPEAK', 'ADD_REACTIONS'])) {
return message.channel.send(':x: Error! In order to do this command, you must give me the permissions to "Connect" and "Speak", as well as the permission to Add Reactions!');
}
else {
let voiceChannel = message.member.voiceChannel;
if (!voiceChannel) {
return message.channel.send(`:x: Error! Please be in a voice channel first!`);
}
else {
let soundToPlay = message.content.toLowerCase().split(" ").slice(1).join(" ");
if (!soundToPlay) {
return message.channel.send(':x: Error! No sound set. Please use ;soundboard list to see a list of sounds you can play.');
}
else if (soundToPlay === 'list') {
return message.channel.send("**Available Sounds:** Cat, Pikachu, Vader, Doh, It's a Trap, Mario Death, Pokemon Center, Dun Dun Dun, Spongebob, Ugly Barnacle, Woo Hoo, Space, GLaDOS Bird, Airhorn, Zelda Chest, Eat my Shorts, No This is Patrick, Wumbo");
}
else if (soundToPlay === sounds.avaliable[soundToPlay]) {
let alreadyConnected = await this.client.voiceConnections.get(voiceChannel.guild.id);
if (alreadyConnected) {
if (alreadyConnected.channel.id === voiceChannel.id) {
return message.channel.send(':x: Error! I am already playing a sound!');
}
else {
return message.channel.send(':x: Error! I am already playing a sound!');
}
}
else {
let connection = await voiceChannel.join();
let stream = sounds.paths[soundToPlay];
let dispatcher = connection.playStream(stream);
message.react('🔊');
dispatcher.on('end', () => {
message.react('✅');
return voiceChannel.leave();
});
}
}
else {
return message.channel.send(':x: Error! Sound not found! Use `;soundboard list` to see a list of sounds you can play.');
}
}
}
}
else {
return message.channel.send(':x: This is a DM!');
let voiceChannel = message.member.voiceChannel;
if (!voiceChannel) return message.channel.send(`:x: Error! Please be in a voice channel first!`);
let soundToPlay = args.sound;
if (soundToPlay === 'list') return message.channel.send("**Available Sounds:** Cat, Pikachu, Vader, Doh, It's a Trap, Mario Death, Pokemon Center, Dun Dun Dun, Spongebob, Ugly Barnacle, Woo Hoo, Space, GLaDOS Bird, Airhorn, Zelda Chest, Eat my Shorts, No This is Patrick, Wumbo");
if (soundToPlay !== sounds.avaliable[soundToPlay]) return message.channel.send(':x: Error! Sound not found! Use `;soundboard list` to see a list of sounds you can play.');
let alreadyConnected = await this.client.voiceConnections.get(voiceChannel.guild.id);
if (alreadyConnected) {
if (alreadyConnected.channel.id === voiceChannel.id) return message.channel.send(':x: Error! I am already playing a sound!');
return message.channel.send(':x: Error! I am already playing a sound!');
}
let connection = await voiceChannel.join();
let stream = sounds.paths[soundToPlay];
let dispatcher = connection.playStream(stream);
message.react('🔊');
dispatcher.on('end', () => {
message.react('✅');
return voiceChannel.leave();
});
}
};
-74
View File
@@ -1,74 +0,0 @@
const commando = require('discord.js-commando');
const Discord = require('discord.js');
module.exports = class TypingGameCommand extends commando.Command {
constructor(Client) {
super(Client, {
name: 'typinggame',
group: 'random',
memberName: 'typinggame',
description: 'See how fast you can type a sentence in a given time limit. (;typinggame easy)',
examples: [';typinggame easy', ';typinggame medium', ';typinggame hard', ';typinggame extreme']
});
}
async run(message) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
}
console.log(`[Command] ${message.content}`);
let [level] = message.content.toLowerCase().split(" ").slice(1);
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;
switch (level) {
case "easy":
time = 25000;
break;
case "medium":
time = 20000;
break;
case "hard":
time = 15000;
break;
case "extreme":
time = 10000;
break;
}
let levelWord;
switch (level) {
case "easy":
levelWord = "twenty-five";
break;
case "medium":
levelWord = "twenty";
break;
case "hard":
levelWord = "fifteen";
break;
case "extreme":
levelWord = "ten";
break;
}
if (!time) {
return message.channel.send(':x: Error! No difficulty set! (Choose Easy, Medium, Hard, or Extreme)');
}
else {
const embed = new Discord.RichEmbed()
.setTitle(`You have **${levelWord}** seconds to type:`)
.setDescription(randomSentence);
let embedMsg = await message.channel.sendEmbed(embed);
try {
let collected = await message.channel.awaitMessages(response => response.content === randomSentence && response.author.id === message.author.id, {
max: 1,
time: time,
errors: ['time']
});
return message.channel.send(`Good Job! You won!`);
}
catch (err) {
return message.channel.send('Aw... Too bad, try again next time!');
}
}
}
};