mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-13 00:09:08 +02:00
Reply to some games and math
This commit is contained in:
@@ -103,14 +103,8 @@ module.exports = class BattleCommand extends Command {
|
||||
}
|
||||
}
|
||||
this.fighting.delete(msg.channel.id);
|
||||
const userWin = userHP > oppoHP;
|
||||
const winner = userWin ? `${msg.author} (${userHP}HP)` : `${opponent} (${oppoHP}HP)`;
|
||||
const loser = userWin ? `${opponent} (${oppoHP}HP)` : `${msg.author} (${userHP}HP)`;
|
||||
return msg.say(stripIndents`
|
||||
The match is over!
|
||||
**Winner**: ${winner}
|
||||
**Loser**: ${loser}
|
||||
`);
|
||||
const winner = userHP > oppoHP ? msg.author : opponent;
|
||||
return msg.say(`The match is over! Congrats, ${winner}!`);
|
||||
} catch (err) {
|
||||
this.fighting.delete(msg.channel.id);
|
||||
throw err;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { createCanvas, registerFont } = require('canvas');
|
||||
const path = require('path');
|
||||
const pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789'.split('');
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Captcha.ttf'), { family: 'Captcha' });
|
||||
|
||||
module.exports = class CaptchaQuizCommand extends Command {
|
||||
@@ -30,7 +31,7 @@ module.exports = class CaptchaQuizCommand extends Command {
|
||||
ctx.font = '26px Captcha';
|
||||
ctx.rotate(-0.05);
|
||||
ctx.strokeText(text, 15, 26);
|
||||
await msg.say(
|
||||
await msg.reply(
|
||||
'**You have 15 seconds, what does the captcha say?**',
|
||||
{ files: [{ attachment: canvas.toBuffer(), name: 'captcha-quiz.png' }] }
|
||||
);
|
||||
@@ -38,13 +39,12 @@ module.exports = class CaptchaQuizCommand extends Command {
|
||||
max: 1,
|
||||
time: 15000
|
||||
});
|
||||
if (!msgs.size) return msg.say(`Sorry, time is up! It was ${text}.`);
|
||||
if (msgs.first().content !== text) return msg.say(`Nope, sorry, it's ${text}.`);
|
||||
return msg.say('Nice job! 10/10! You deserve some cake!');
|
||||
if (!msgs.size) return msg.reply(`Sorry, time is up! It was ${text}.`);
|
||||
if (msgs.first().content !== text) return msg.reply(`Nope, sorry, it's ${text}.`);
|
||||
return msg.reply('Nice job! 10/10! You deserve some cake!');
|
||||
}
|
||||
|
||||
randomText(len) {
|
||||
const pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789'.split('');
|
||||
const result = [];
|
||||
for (let i = 0; i < len; i++) result.push(pool[Math.floor(Math.random() * pool.length)]);
|
||||
return result.join('');
|
||||
|
||||
@@ -22,6 +22,6 @@ module.exports = class FishyCommand extends Command {
|
||||
else rarity = 'rare';
|
||||
const fish = fishes[rarity];
|
||||
const worth = randomRange(fish.min, fish.max);
|
||||
return msg.say(`You caught a ${fish.symbol}. I bet it'd sell for around $${worth}.`);
|
||||
return msg.reply(`You caught a ${fish.symbol}. I bet it'd sell for around $${worth}.`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ module.exports = class LotteryCommand extends Command {
|
||||
run(msg, { choices }) {
|
||||
const lotto = Array.from({ length: 6 }, () => Math.floor(Math.random() * 70) + 1);
|
||||
const similarities = lotto.filter((num, i) => choices[i] === num).length;
|
||||
return msg.say(stripIndents`
|
||||
return msg.reply(stripIndents`
|
||||
${lotto.join(', ')}
|
||||
You matched **${similarities}** numbers, which gives you **${prizes[similarities]}**! Congrats!
|
||||
`);
|
||||
|
||||
@@ -42,7 +42,7 @@ module.exports = class MathQuizCommand extends Command {
|
||||
case '-': answer = value1 - value2; break;
|
||||
case '*': answer = value1 * value2; break;
|
||||
}
|
||||
await msg.say(stripIndents`
|
||||
await msg.reply(stripIndents`
|
||||
**You have 10 seconds to answer this question.**
|
||||
${value1} ${operation} ${value2}
|
||||
`);
|
||||
@@ -50,8 +50,8 @@ module.exports = class MathQuizCommand extends Command {
|
||||
max: 1,
|
||||
time: 10000
|
||||
});
|
||||
if (!msgs.size) return msg.say(`Sorry, time is up! It was ${answer}.`);
|
||||
if (msgs.first().content !== answer.toString()) return msg.say(`Nope, sorry, it's ${answer}.`);
|
||||
return msg.say('Nice job! 10/10! You deserve some cake!');
|
||||
if (!msgs.size) return msg.reply(`Sorry, time is up! It was ${answer}.`);
|
||||
if (msgs.first().content !== answer.toString()) return msg.reply(`Nope, sorry, it's ${answer}.`);
|
||||
return msg.reply('Nice job! 10/10! You deserve some cake!');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@ module.exports = class QuizCommand extends Command {
|
||||
const correct = decodeURIComponent(body.results[0].correct_answer.toLowerCase());
|
||||
answers.push(correct);
|
||||
const shuffled = shuffle(answers);
|
||||
await msg.say(stripIndents`
|
||||
await msg.reply(stripIndents`
|
||||
**You have 15 seconds to answer this question.**
|
||||
${decodeURIComponent(body.results[0].question)}
|
||||
${shuffled.map((answer, i) => `**${choices[i]}**. ${answer}`).join('\n')}
|
||||
@@ -64,10 +64,10 @@ module.exports = class QuizCommand extends Command {
|
||||
max: 1,
|
||||
time: 15000
|
||||
});
|
||||
if (!msgs.size) return msg.say(`Sorry, time is up! It was ${correct}.`);
|
||||
if (!msgs.size) return msg.reply(`Sorry, time is up! It was ${correct}.`);
|
||||
const win = shuffled[choices.indexOf(msgs.first().content.toUpperCase())] === correct;
|
||||
if (!win) return msg.say(`Nope, sorry, it's ${correct}.`);
|
||||
return msg.say('Nice job! 10/10! You deserve some cake!');
|
||||
if (!win) return msg.reply(`Nope, sorry, it's ${correct}.`);
|
||||
return msg.reply('Nice job! 10/10! You deserve some cake!');
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
@@ -23,20 +23,20 @@ module.exports = class RockPaperScissorsCommand extends Command {
|
||||
run(msg, { choice }) {
|
||||
const response = choices[Math.floor(Math.random() * choices.length)];
|
||||
if (choice === 'rock') {
|
||||
if (response === 'rock') return msg.say('Rock! Aw... A tie...');
|
||||
if (response === 'paper') return msg.say('Paper! Yes! I win!');
|
||||
if (response === 'scissors') return msg.say('Scissors! Aw... I lose...');
|
||||
if (response === 'rock') return msg.reply('Rock! Aw... A tie...');
|
||||
if (response === 'paper') return msg.reply('Paper! Yes! I win!');
|
||||
if (response === 'scissors') return msg.reply('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 (response === 'rock') return msg.reply('Rock! Aw... I lose...');
|
||||
if (response === 'paper') return msg.reply('Paper! Aw... A tie...');
|
||||
if (response === 'scissors') return msg.reply('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...');
|
||||
if (response === 'rock') return msg.reply('Rock! Yes! I win!');
|
||||
if (response === 'paper') return msg.reply('Paper! Aw... I lose...');
|
||||
if (response === 'scissors') return msg.reply('Scissors! Aw... A tie...');
|
||||
}
|
||||
return msg.say('I win by default, you little cheater.');
|
||||
return msg.reply('I win by default, you little cheater.');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,12 +17,12 @@ module.exports = class SlotsCommand extends Command {
|
||||
const slotTwo = slots[Math.floor(Math.random() * slots.length)];
|
||||
const slotThree = slots[Math.floor(Math.random() * slots.length)];
|
||||
if (slotOne === slotTwo && slotOne === slotThree) {
|
||||
return msg.say(stripIndents`
|
||||
return msg.reply(stripIndents`
|
||||
${slotOne}|${slotTwo}|${slotThree}
|
||||
Wow! You won! Great job... er... luck!
|
||||
`);
|
||||
}
|
||||
return msg.say(stripIndents`
|
||||
return msg.reply(stripIndents`
|
||||
${slotOne}|${slotTwo}|${slotThree}
|
||||
Aww... You lost... Guess it's just bad luck, huh?
|
||||
`);
|
||||
|
||||
@@ -35,7 +35,7 @@ module.exports = class TypingTestCommand extends Command {
|
||||
async run(msg, { difficulty }) {
|
||||
const sentence = sentences[Math.floor(Math.random() * sentences.length)];
|
||||
const time = times[difficulty];
|
||||
await msg.say(stripIndents`
|
||||
await msg.reply(stripIndents`
|
||||
**You have ${time / 1000} seconds to type this sentence.**
|
||||
${sentence}
|
||||
`);
|
||||
@@ -44,7 +44,7 @@ module.exports = class TypingTestCommand extends Command {
|
||||
max: 1,
|
||||
time
|
||||
});
|
||||
if (!msgs.size || msgs.first().content !== sentence) return msg.say('Sorry! You lose!');
|
||||
return msg.say(`Nice job! 10/10! You deserve some cake! (Took ${(Date.now() - now) / 1000} seconds)`);
|
||||
if (!msgs.size || msgs.first().content !== sentence) return msg.reply('Sorry! You lose!');
|
||||
return msg.reply(`Nice job! 10/10! You deserve some cake! (Took ${(Date.now() - now) / 1000} seconds)`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -37,14 +37,14 @@ module.exports = class WhosThatPokemonCommand extends Command {
|
||||
const displayName = data.names.filter(name => name.language.name === 'en')[0].name;
|
||||
const id = data.id.toString().padStart(3, '0');
|
||||
const attachment = await this.fetchImage(id, hide);
|
||||
await msg.say('**You have 15 seconds, who\'s that Pokémon?**', { files: [{ attachment, name: `${id}.png` }] });
|
||||
await msg.reply('**You have 15 seconds, who\'s that Pokémon?**', { files: [{ attachment, name: `${id}.png` }] });
|
||||
const msgs = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, {
|
||||
max: 1,
|
||||
time: 15000
|
||||
});
|
||||
if (!msgs.size) return msg.say(`Sorry, time is up! It was ${displayName}.`);
|
||||
if (!names.includes(msgs.first().content.toLowerCase())) return msg.say(`Nope, sorry, it's ${displayName}.`);
|
||||
return msg.say('Nice job! 10/10! You deserve some cake!');
|
||||
if (!msgs.size) return msg.reply(`Sorry, time is up! It was ${displayName}.`);
|
||||
if (!names.includes(msgs.first().content.toLowerCase())) return msg.reply(`Nope, sorry, it's ${displayName}.`);
|
||||
return msg.reply('Nice job! 10/10! You deserve some cake!');
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ module.exports = class MathCommand extends Command {
|
||||
run(msg, { expression }) {
|
||||
try {
|
||||
const evaluated = math.eval(expression).toString();
|
||||
return msg.say(evaluated).catch(() => msg.say('Invalid expression.'));
|
||||
return msg.reply(evaluated).catch(() => msg.reply('Invalid expression.'));
|
||||
} catch (err) {
|
||||
return msg.say('Invalid expression.');
|
||||
return msg.reply('Invalid expression.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@ module.exports = class WhitelistCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'whitelist',
|
||||
aliases: ['blacklist-remove', 'blacklist-delete'],
|
||||
aliases: ['blacklist-remove', 'blacklist-delete', 'unblacklist'],
|
||||
group: 'util',
|
||||
memberName: 'whitelist',
|
||||
description: 'Removes a user from the blacklist.',
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "75.1.1",
|
||||
"version": "75.1.2",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user