mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-05 22:01:54 +02:00
Change in the way Games Commands work
This commit is contained in:
@@ -10,10 +10,6 @@ module.exports = class MathGameCommand extends commando.Command {
|
||||
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'],
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
args: [{
|
||||
key: 'difficulty',
|
||||
prompt: 'What difficulty should the math game be? easy, medium, hard, or extreme?',
|
||||
@@ -60,11 +56,15 @@ module.exports = class MathGameCommand extends commando.Command {
|
||||
.setDescription(randomExpression);
|
||||
let embedMsg = await message.embed(embed);
|
||||
try {
|
||||
let collected = await message.channel.awaitMessages(response => response.content === solved.toString() && response.author.id === message.author.id, {
|
||||
let collected = await message.channel.awaitMessages(response => response.author.id === message.author.id, {
|
||||
max: 1,
|
||||
time: 10000,
|
||||
errors: ['time'],
|
||||
});
|
||||
if (collected.first() !== solved.toString()) {
|
||||
let loseMsg = await message.say(`Aw... Too bad, try again next time!\nThe correct answer is: ${solved}`);
|
||||
return [embedMsg, loseMsg];
|
||||
}
|
||||
let victoryMsg = await message.say(`Good Job! You won! ${solved} is the correct answer!`);
|
||||
return [embedMsg, victoryMsg];
|
||||
}
|
||||
|
||||
@@ -12,11 +12,7 @@ module.exports = class QuizCommand extends commando.Command {
|
||||
group: 'games',
|
||||
memberName: 'quiz',
|
||||
description: 'Answer a quiz question. (;quiz)',
|
||||
examples: [';quiz'],
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 15
|
||||
},
|
||||
examples: [';quiz']
|
||||
});
|
||||
}
|
||||
|
||||
@@ -37,12 +33,16 @@ module.exports = class QuizCommand extends commando.Command {
|
||||
.setDescription(`**Category: ${response.body[0].category.title}**\n${response.body[0].question}`);
|
||||
let embedMsg = await message.embed(embed);
|
||||
try {
|
||||
let collected = await message.channel.awaitMessages(res => res.content.toLowerCase() === answer && res.author.id === message.author.id, {
|
||||
let collected = await message.channel.awaitMessages(res => res.author.id === message.author.id, {
|
||||
max: 1,
|
||||
time: 15000,
|
||||
errors: ['time']
|
||||
});
|
||||
let victoryMsg = await message.say(`Good Job! You won! ${answer} is the correct answer!`);
|
||||
if (collected.first().toLowerCase() !== answer) {
|
||||
let loseMsg = await message.say(`The correct answer is: ${answer}`);
|
||||
return [embedMsg, loseMsg];
|
||||
}
|
||||
let victoryMsg = await message.say(`The correct answer is: ${answer}`);
|
||||
return [embedMsg, victoryMsg];
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -9,10 +9,6 @@ module.exports = class TypingGameCommand extends commando.Command {
|
||||
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'],
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 25
|
||||
},
|
||||
args: [{
|
||||
key: 'difficulty',
|
||||
prompt: 'What difficulty should the typing game be? Easy, Medium, Hard, or Extreme?',
|
||||
@@ -61,11 +57,15 @@ module.exports = class TypingGameCommand extends commando.Command {
|
||||
.setDescription(randomSentence);
|
||||
let embedMsg = await message.embed(embed);
|
||||
try {
|
||||
let collected = await message.channel.awaitMessages(response => response.content === randomSentence && response.author.id === message.author.id, {
|
||||
let collected = await message.channel.awaitMessages(response => response.author.id === message.author.id, {
|
||||
max: 1,
|
||||
time: time,
|
||||
errors: ['time']
|
||||
});
|
||||
if (collected.first() !== randomSentence) {
|
||||
let loseMsg = await message.say('Nope, your sentence does not match the original. Try again next time!');
|
||||
return [embedMsg, loseMsg];
|
||||
}
|
||||
let victoryMsg = await message.say(`Good Job! You won!`);
|
||||
return [embedMsg, victoryMsg];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user