mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 14:19:11 +02:00
Lots of Changes
This commit is contained in:
@@ -9,11 +9,10 @@ module.exports = class BattleCommand extends Command {
|
||||
group: 'games',
|
||||
memberName: 'battle',
|
||||
description: 'Engage in a turn-based battle against another user or the AI.',
|
||||
guildOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'opponent',
|
||||
prompt: 'Who would you like to battle?',
|
||||
prompt: 'What user would you like to battle?',
|
||||
type: 'user',
|
||||
default: ''
|
||||
}
|
||||
@@ -26,17 +25,17 @@ module.exports = class BattleCommand extends Command {
|
||||
async run(msg, args) { // eslint-disable-line complexity
|
||||
const opponent = args.opponent || this.client.user;
|
||||
if (opponent.id === msg.author.id) return msg.say('You may not fight yourself.');
|
||||
if (this.fighting.has(msg.guild.id)) return msg.say('Only one fight may be occurring per server.');
|
||||
this.fighting.add(msg.guild.id);
|
||||
if (this.fighting.has(msg.channel.id)) return msg.say('Only one fight may be occurring per channel.');
|
||||
this.fighting.add(msg.channel.id);
|
||||
try {
|
||||
if (!opponent.bot) {
|
||||
await msg.say(`${opponent}, do you accept this challenge? **__Y__es** or **No**?`);
|
||||
await msg.say(`${opponent}, do you accept this challenge?`);
|
||||
const verify = await msg.channel.awaitMessages(res => res.author.id === opponent.id, {
|
||||
max: 1,
|
||||
time: 30000
|
||||
});
|
||||
if (!verify.size || !['yes', 'y'].includes(verify.first().content.toLowerCase())) {
|
||||
this.fighting.delete(msg.guild.id);
|
||||
this.fighting.delete(msg.channel.id);
|
||||
return msg.say('Looks like they declined...');
|
||||
}
|
||||
}
|
||||
@@ -65,7 +64,7 @@ module.exports = class BattleCommand extends Command {
|
||||
await msg.say(stripIndents`
|
||||
${user}, do you **fight**, **guard**, **special**, or **run**?
|
||||
**${msg.author.username}**: ${userHP}HP
|
||||
**${opponent === 'AI' ? 'AI' : opponent.username}**: ${oppoHP}HP
|
||||
**${opponent.username}**: ${oppoHP}HP
|
||||
`);
|
||||
const turn = await msg.channel.awaitMessages(res => res.author.id === id, {
|
||||
max: 1,
|
||||
@@ -109,15 +108,15 @@ module.exports = class BattleCommand extends Command {
|
||||
await msg.say(`${user}, I do not understand what you want to do.`);
|
||||
}
|
||||
}
|
||||
this.fighting.delete(msg.guild.id);
|
||||
this.fighting.delete(msg.channel.id);
|
||||
return msg.say(stripIndents`
|
||||
The match is over!
|
||||
**Winner:** ${userHP > oppoHP ? `${msg.author} (${userHP}HP)` : `${opponent} (${oppoHP}HP)`}
|
||||
**Loser:** ${userHP > oppoHP ? `${opponent} (${oppoHP}HP)` : `${msg.author} (${userHP}HP)`}
|
||||
`);
|
||||
} catch (err) {
|
||||
this.fighting.delete(msg.guild.id);
|
||||
return msg.say(`Oh no, an Error occurred: \`${err.message}\`. Try again later!`);
|
||||
this.fighting.delete(msg.channel.id);
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@ module.exports = class FishyCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'fishy',
|
||||
aliases: ['fish'],
|
||||
group: 'games',
|
||||
memberName: 'fishy',
|
||||
description: 'Catches a fish.'
|
||||
|
||||
@@ -27,16 +27,16 @@ module.exports = class GunfightCommand extends Command {
|
||||
const { opponent } = args;
|
||||
if (opponent.bot) return msg.say('Bots may not be fought.');
|
||||
if (opponent.id === msg.author.id) return msg.say('You may not fight yourself.');
|
||||
if (this.fighting.has(msg.guild.id)) return msg.say('Only one fight may be occurring per server.');
|
||||
this.fighting.add(msg.guild.id);
|
||||
if (this.fighting.has(msg.channel.id)) return msg.say('Only one fight may be occurring per channel.');
|
||||
this.fighting.add(msg.channel.id);
|
||||
try {
|
||||
await msg.say(`${opponent}, do you accept this challenge? **__Y__es** or **No**?`);
|
||||
await msg.say(`${opponent}, do you accept this challenge?`);
|
||||
const verify = await msg.channel.awaitMessages(res => res.author.id === opponent.id, {
|
||||
max: 1,
|
||||
time: 30000
|
||||
});
|
||||
if (!verify.size || !['yes', 'y'].includes(verify.first().content.toLowerCase())) {
|
||||
this.fighting.delete(msg.guild.id);
|
||||
this.fighting.delete(msg.channel.id);
|
||||
return msg.say('Looks like they declined...');
|
||||
}
|
||||
await msg.say('Get Ready...');
|
||||
@@ -49,12 +49,12 @@ module.exports = class GunfightCommand extends Command {
|
||||
max: 1,
|
||||
time: 30000
|
||||
});
|
||||
this.fighting.delete(msg.guild.id);
|
||||
this.fighting.delete(msg.channel.id);
|
||||
if (!winner.size) return msg.say('Oh... No one won.');
|
||||
return msg.say(`And the winner is ${winner.first().author.username}!`);
|
||||
} catch (err) {
|
||||
this.fighting.delete(msg.guild.id);
|
||||
return msg.say(`Oh no, an Error occurred: \`${err.message}\`. Try again later!`);
|
||||
this.fighting.delete(msg.channel.id);
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,8 +17,8 @@ module.exports = class HangmanCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
if (this.playing.has(msg.guild.id)) return msg.say('Only one game may be occurring per server.');
|
||||
this.playing.add(msg.guild.id);
|
||||
if (this.playing.has(msg.channel.id)) return msg.say('Only one game may be occurring per channel.');
|
||||
this.playing.add(msg.channel.id);
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('http://api.wordnik.com:80/v4/words.json/randomWord')
|
||||
@@ -32,7 +32,7 @@ module.exports = class HangmanCommand extends Command {
|
||||
maxLength: -1,
|
||||
api_key: WORDNIK_KEY
|
||||
});
|
||||
const word = body.word.toLowerCase().replace(/[ ]/g, '-');
|
||||
const word = body.word.toLowerCase().replace(/ /g, '-');
|
||||
let points = 0;
|
||||
const confirmation = [];
|
||||
const incorrect = [];
|
||||
@@ -61,10 +61,9 @@ module.exports = class HangmanCommand extends Command {
|
||||
} else if (word.includes(choice)) {
|
||||
await msg.say('Nice job!');
|
||||
for (let i = 0; i < word.length; i++) {
|
||||
if (word[i] === choice) { // eslint-disable-line max-depth
|
||||
confirmation.push(word[i]);
|
||||
display[i] = word[i];
|
||||
}
|
||||
if (word[i] !== choice) continue; // eslint-disable-line max-depth
|
||||
confirmation.push(word[i]);
|
||||
display[i] = word[i];
|
||||
}
|
||||
} else {
|
||||
await msg.say('Nope!');
|
||||
@@ -72,12 +71,12 @@ module.exports = class HangmanCommand extends Command {
|
||||
points++;
|
||||
}
|
||||
}
|
||||
this.playing.delete(msg.guild.id);
|
||||
this.playing.delete(msg.channel.id);
|
||||
if (word.length === confirmation.length) return msg.say(`You won, it was ${word}!`);
|
||||
return msg.say(`Too bad... It was ${word}...`);
|
||||
} catch (err) {
|
||||
this.playing.delete(msg.guild.id);
|
||||
return msg.say(`Oh no, an Error occurred: \`${err.message}\`. Try again later!`);
|
||||
this.playing.delete(msg.channel.id);
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ module.exports = class LotteryCommand extends Command {
|
||||
|
||||
run(msg) {
|
||||
const lottery = Math.floor(Math.random() * 100) + 1;
|
||||
if (lottery === 1) return msg.reply(`Wow! You actually won! Great job!`);
|
||||
return msg.reply(`Nope, sorry, you lost.`);
|
||||
if (lottery === 1) return msg.reply('Nice job! 10/10! You deserve some cake!');
|
||||
return msg.reply('Nope, sorry, you lost.');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,7 +1,22 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const math = require('mathjs');
|
||||
const { operations, difficulties, maxValues } = require('../../assets/json/math-game');
|
||||
const { list } = require('../../structures/Util');
|
||||
const difficulties = ['easy', 'medium', 'hard', 'extreme', 'impossible'];
|
||||
const operations = {
|
||||
easy: ['+', '-'],
|
||||
medium: ['+', '-'],
|
||||
hard: ['-', '*'],
|
||||
extreme: ['*', '/'],
|
||||
impossible: ['/', '^']
|
||||
};
|
||||
const maxValues = {
|
||||
easy: 5,
|
||||
medium: 10,
|
||||
hard: 50,
|
||||
extreme: 75,
|
||||
impossible: 100
|
||||
};
|
||||
|
||||
module.exports = class MathGameCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -14,11 +29,11 @@ module.exports = class MathGameCommand extends Command {
|
||||
args: [
|
||||
{
|
||||
key: 'difficulty',
|
||||
prompt: `What should the difficulty of the game be? One of: ${difficulties.join(', ')}`,
|
||||
prompt: `What should the difficulty of the game be? Either ${list(difficulties, 'or')}.`,
|
||||
type: 'string',
|
||||
validate: difficulty => {
|
||||
if (difficulties.includes(difficulty.toLowerCase())) return true;
|
||||
return `The difficulty must be one of: ${difficulties.join(', ')}`;
|
||||
return `Invalid difficulty, please enter either ${list(difficulties, 'or')}.`;
|
||||
},
|
||||
parse: difficulty => difficulty.toLowerCase()
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ const { MessageEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { shuffle, list } = require('../../structures/Util');
|
||||
const types = ['multiple', 'boolean'];
|
||||
const difficulties = ['easy', 'medium', 'hard'];
|
||||
|
||||
module.exports = class QuizCommand extends Command {
|
||||
@@ -17,22 +18,22 @@ module.exports = class QuizCommand extends Command {
|
||||
args: [
|
||||
{
|
||||
key: 'type',
|
||||
prompt: 'Which type of question would you like to have? `multiple` or `boolean`.',
|
||||
prompt: `Which type of question would you like to have? Either ${list(types, 'or')}.`,
|
||||
type: 'string',
|
||||
validate: type => {
|
||||
if (['multiple', 'boolean'].includes(type.toLowerCase())) return true;
|
||||
return 'Please enter either `multiple` or `boolean`.';
|
||||
if (types.includes(type.toLowerCase())) return true;
|
||||
return `Invalid type, please enter either ${list(types, 'or')}.`;
|
||||
},
|
||||
parse: type => type.toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'difficulty',
|
||||
prompt: `What should the difficulty of the game be? One of: ${difficulties.join(', ')}`,
|
||||
prompt: `What should the difficulty of the game be? Either ${list(difficulties, 'or')}.`,
|
||||
type: 'string',
|
||||
default: '',
|
||||
validate: difficulty => {
|
||||
if (difficulties.includes(difficulty.toLowerCase())) return true;
|
||||
return `The difficulty must be one of: ${difficulties.join(', ')}`;
|
||||
return `Invalid difficulty, please enter either ${list(difficulties, 'or')}.`;
|
||||
},
|
||||
parse: difficulty => difficulty.toLowerCase()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const choices = ['paper', 'rock', 'scissors'];
|
||||
const choices = ['rock', 'paper', 'scissors'];
|
||||
|
||||
module.exports = class RockPaperScissorsCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -20,23 +20,24 @@ module.exports = class RockPaperScissorsCommand extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, args) { // eslint-disable-line consistent-return
|
||||
run(msg, args) {
|
||||
const { choice } = args;
|
||||
const response = choices[Math.floor(Math.random() * choices.length)];
|
||||
if (choice === 'rock') {
|
||||
if (response === 'rock') return msg.say('Rock! Aw... A tie...');
|
||||
else if (response === 'paper') return msg.say('Paper! Yes! I win!');
|
||||
else if (response === 'scissors') return msg.say('Scissors! Aw... I lose...');
|
||||
} else if (choice === 'paper') {
|
||||
if (response === 'rock') return msg.say('Rock! Aw... I lose...');
|
||||
else if (response === 'paper') return msg.say('Paper! Aw... A tie...');
|
||||
else if (response === 'scissors') return msg.say('Scissors! Yes! I win!');
|
||||
} else if (choice === 'scissors') {
|
||||
if (response === 'rock') return msg.say('Rock! Yes! I win!');
|
||||
else if (response === 'paper') return msg.say('Paper! Aw... I lose...');
|
||||
else if (response === 'scissors') return msg.say('Scissors! Aw... A tie...');
|
||||
} else {
|
||||
return msg.say('I win by default, you little cheater.');
|
||||
if (response === 'paper') return msg.say('Paper! Yes! I win!');
|
||||
if (response === 'scissors') return msg.say('Scissors! Aw... I lose...');
|
||||
}
|
||||
if (choice === 'paper') {
|
||||
if (response === 'rock') return msg.say('Rock! Aw... I lose...');
|
||||
if (response === 'paper') return msg.say('Paper! Aw... A tie...');
|
||||
if (response === 'scissors') return msg.say('Scissors! Yes! I win!');
|
||||
}
|
||||
if (choice === 'scissors') {
|
||||
if (response === 'rock') return msg.say('Rock! Yes! I win!');
|
||||
if (response === 'paper') return msg.say('Paper! Aw... I lose...');
|
||||
if (response === 'scissors') return msg.say('Scissors! Aw... A tie...');
|
||||
}
|
||||
return msg.say('I win by default, you little cheater.');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,11 +21,10 @@ module.exports = class SlotsCommand extends Command {
|
||||
${slotOne}|${slotTwo}|${slotThree}
|
||||
Wow! You won! Great job... er... luck!
|
||||
`);
|
||||
} else {
|
||||
return msg.say(stripIndents`
|
||||
${slotOne}|${slotTwo}|${slotThree}
|
||||
Aww... You lost... Guess it's just bad luck, huh?
|
||||
`);
|
||||
}
|
||||
return msg.say(stripIndents`
|
||||
${slotOne}|${slotTwo}|${slotThree}
|
||||
Aww... You lost... Guess it's just bad luck, huh?
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { sentences, difficulties, times } = require('../../assets/json/typing-game');
|
||||
const { list } = require('../../structures/Util');
|
||||
const difficulties = ['easy', 'medium', 'hard', 'extreme', 'impossible'];
|
||||
const times = {
|
||||
easy: 25000,
|
||||
medium: 20000,
|
||||
hard: 15000,
|
||||
extreme: 10000,
|
||||
impossible: 5000
|
||||
};
|
||||
const sentences = require('../../assets/json/typing-game');
|
||||
|
||||
module.exports = class TypingGameCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -13,11 +22,11 @@ module.exports = class TypingGameCommand extends Command {
|
||||
args: [
|
||||
{
|
||||
key: 'difficulty',
|
||||
prompt: `What should the difficulty of the game be? One of: ${difficulties.join(', ')}`,
|
||||
prompt: `What should the difficulty of the game be? Either ${list(difficulties, 'or')}.`,
|
||||
type: 'string',
|
||||
validate: difficulty => {
|
||||
if (difficulties.includes(difficulty.toLowerCase())) return true;
|
||||
return `The difficulty must be one of: ${difficulties.join(', ')}`;
|
||||
return `Invalid difficulty, please enter either ${list(difficulties, 'or')}.`;
|
||||
},
|
||||
parse: difficulty => difficulty.toLowerCase()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user