Beep beep

This commit is contained in:
Daniel Odendahl Jr
2017-10-08 18:59:52 +00:00
parent 3ed9f7a423
commit 6a9d24cf87
18 changed files with 150 additions and 116 deletions
+2 -2
View File
@@ -28,7 +28,7 @@ module.exports = class AkinatorCommand extends Command {
answers.push('end');
await msg.say(stripIndents`
**${++data.step}.** ${data.question}
${data.answers.map(answer => answer.answer).join(' | ')} | End
${data.answers.map(answer => answer.answer).join(' | ')}
`);
const filter = res => res.author.id === msg.author.id && answers.includes(res.content.toLowerCase());
const msgs = await msg.channel.awaitMessages(filter, {
@@ -63,7 +63,7 @@ module.exports = class AkinatorCommand extends Command {
return msg.say(response === 'yes' ? 'Another win for me!' : 'Bravo, you have defeated me.');
} catch (err) {
this.sessions.delete(msg.channel.id);
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
throw err;
}
}
+2 -3
View File
@@ -70,8 +70,7 @@ module.exports = class BattleCommand extends Command {
});
if (!turn.size) {
await msg.say('Time!');
forfeit();
break;
continue;
}
choice = turn.first().content.toLowerCase();
} else {
@@ -114,7 +113,7 @@ module.exports = class BattleCommand extends Command {
`);
} catch (err) {
this.fighting.delete(msg.channel.id);
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
throw err;
}
}
};
+1 -1
View File
@@ -68,7 +68,7 @@ module.exports = class EmojiEmojiRevolutionCommand extends Command {
return msg.say(`You win ${aPts > oPts ? msg.author : opponent} with ${aPts > oPts ? aPts : oPts} points!`);
} catch (err) {
this.playing.delete(msg.channel.id);
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
throw err;
}
}
};
+1 -1
View File
@@ -53,7 +53,7 @@ module.exports = class GunfightCommand extends Command {
return msg.say(`And the winner is ${winner.first().author.username}!`);
} catch (err) {
this.fighting.delete(msg.channel.id);
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
throw err;
}
}
};
+1
View File
@@ -54,6 +54,7 @@ module.exports = class HangmanCommand extends Command {
break;
}
const choice = guess.first().content.toLowerCase();
if (choice === 'end') break;
if (confirmation.includes(choice) || incorrect.includes(choice)) {
await msg.say('You have already picked that letter!');
} else if (word.includes(choice)) {
+7 -5
View File
@@ -1,5 +1,4 @@
const { Command } = require('discord.js-commando');
const math = require('mathjs');
const { stripIndents } = require('common-tags');
const { list } = require('../../structures/Util');
const difficulties = ['easy', 'medium', 'hard', 'extreme', 'impossible'];
@@ -20,7 +19,6 @@ module.exports = class MathGameCommand extends Command {
group: 'games',
memberName: 'math-game',
description: 'See how fast you can answer a math problem in a given time limit.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'difficulty',
@@ -40,11 +38,15 @@ module.exports = class MathGameCommand extends Command {
const value1 = Math.floor(Math.random() * maxValues[difficulty]) + 1;
const value2 = Math.floor(Math.random() * maxValues[difficulty]) + 1;
const operation = operations[Math.floor(Math.random() * operations.length)];
const expression = `${value1} ${operation} ${value2}`;
const answer = math.eval(expression).toString();
let answer;
switch (operation) {
case '+': answer = value1 + value2; break;
case '-': answer = value1 - value2; break;
case '*': answer = value1 * value2; break;
}
await msg.say(stripIndents`
**You have 10 seconds to answer this question.**
${expression}
${value1} ${operation} ${value2}
`);
const msgs = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, {
max: 1,
-1
View File
@@ -13,7 +13,6 @@ module.exports = class QuizCommand extends Command {
group: 'games',
memberName: 'quiz',
description: 'Answer a quiz question.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'type',
+3 -3
View File
@@ -37,7 +37,7 @@ module.exports = class QuizletGameCommand extends Command {
while (terms.length > 0) {
const term = terms[0];
await msg.say(stripIndents`
**You have 30 seconds to answer which word this is.** _Type "end game" to end the game._
**You have 30 seconds to answer which word this is.**
${term.definition}
${term.image ? term.image.url : ''}
`);
@@ -47,10 +47,10 @@ module.exports = class QuizletGameCommand extends Command {
});
if (!msgs.size) {
await msg.say('Time!');
break;
continue;
}
const choice = msgs.first().content.toLowerCase();
if (choice === 'end game') break;
if (choice === 'end') break;
if (choice !== term.term.toLowerCase()) {
await msg.say(`Nope, sorry, it was ${term.term}.`);
if (seen.has(term.term)) seen.delete(term.term);
+4 -3
View File
@@ -56,9 +56,10 @@ module.exports = class TicTacToeCommand extends Command {
});
if (!turn.size) {
await msg.say('Time!');
break;
continue;
}
const choice = turn.first().content;
const choice = turn.first().content.toLowerCase();
if (choice === 'end') break;
if (taken.includes(choice)) {
await msg.say('That spot is already taken!');
} else if (!sides.includes(choice)) {
@@ -83,7 +84,7 @@ module.exports = class TicTacToeCommand extends Command {
return msg.say(winner ? `Congrats, ${winner}!` : 'Oh... The cat won.');
} catch (err) {
this.playing.delete(msg.channel.id);
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
throw err;
}
}
};
-1
View File
@@ -19,7 +19,6 @@ module.exports = class TypingGameCommand extends Command {
group: 'games',
memberName: 'typing-game',
description: 'See how fast you can type a sentence in a given time limit.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'difficulty',
+1 -2
View File
@@ -10,8 +10,7 @@ module.exports = class WhosThatPokemonCommand extends Command {
aliases: ['who-pokemon', 'whos-that-pokémon', 'who-pokémon'],
group: 'games',
memberName: 'whos-that-pokemon',
description: 'Guess who that Pokémon is.',
clientPermissions: ['EMBED_LINKS']
description: 'Guess who that Pokémon is.'
});
}
-29
View File
@@ -1,29 +0,0 @@
const { Command } = require('discord.js-commando');
const math = require('mathjs');
module.exports = class MathCommand extends Command {
constructor(client) {
super(client, {
name: 'math',
aliases: ['calculator', 'calculate', 'calc'],
group: 'num-edit',
memberName: 'math',
description: 'Calculates math expressions.',
args: [
{
key: 'expression',
prompt: 'What expression would you like to calculate?',
type: 'string'
}
]
});
}
run(msg, { expression }) {
try {
return msg.say(math.eval(expression).toString()).catch(() => msg.say('Invalid expression.'));
} catch (err) {
return msg.say('Invalid expression.');
}
}
};
-1
View File
@@ -9,7 +9,6 @@ module.exports = class DiscriminatorCommand extends Command {
group: 'other',
memberName: 'discriminator',
description: 'Searches for other users with a certain discriminator.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'discrim',
+4 -15
View File
@@ -1,6 +1,5 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
const { stripIndents } = require('common-tags');
const questions = require('../../assets/json/would-you-rather');
module.exports = class WouldYouRatherCommand extends Command {
constructor(client) {
@@ -9,21 +8,11 @@ module.exports = class WouldYouRatherCommand extends Command {
aliases: ['wy-rather'],
group: 'random-res',
memberName: 'would-you-rather',
description: 'Responds with a random would you rather question.',
clientPermissions: ['EMBED_LINKS']
description: 'Responds with a random would you rather question.'
});
}
async run(msg) {
try {
const { body } = await snekfetch
.get('http://www.rrrather.com/botapi');
return msg.say(stripIndents`
${body.title}...
${body.choicea} OR ${body.choiceb}?
`);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
run(msg) {
return msg.say(questions[Math.floor(Math.random() * questions.length)]);
}
};
+1 -1
View File
@@ -43,7 +43,7 @@ module.exports = class DECTalkCommand extends Command {
try {
const connection = await channel.join();
const { body } = await snekfetch
.get('http://tts.cyzon.us/tts', { followRedirects: true })
.get('http://tts.cyzon.us/tts')
.query({ text });
await fs.writeFileAsync(file, body, { encoding: 'binary' });
const dispatcher = connection.playFile(file);
-46
View File
@@ -1,46 +0,0 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const { duration } = require('../../structures/Util');
module.exports = class ShardInfoCommand extends Command {
constructor(client) {
super(client, {
name: 'shard-info',
aliases: ['shard', 'shard-stats'],
group: 'util',
memberName: 'shard-info',
description: 'Responds with detailed information for a specific Shard.',
guarded: true,
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'shard',
prompt: 'Which Shard would you like to get data for?',
type: 'integer',
default: '',
validate: shard => {
if (shard < this.client.options.shardCount && shard > -1) return true;
return 'Invalid Shard ID.';
}
}
]
});
}
async run(msg, { shard }) {
if (!shard && shard !== 0) shard = this.client.shard.id;
const uptime = await this.client.shard.fetchClientValues('uptime');
const guilds = await this.client.shard.fetchClientValues('guilds.size');
const users = await this.client.shard.fetchClientValues('users.size');
const embed = new MessageEmbed()
.setTitle(`Shard ${shard}`)
.setColor(0x00AE86)
.addField(' Servers',
guilds[shard], true)
.addField(' Users',
users[shard], true)
.addField(' Uptime',
duration(uptime[shard]).format(), true);
return msg.embed(embed);
}
};