mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
const Command = require('../../framework/Command');
|
|
const choices = ['rock', 'paper', 'scissors'];
|
|
|
|
module.exports = class RockPaperScissorsCommand extends Command {
|
|
constructor(client) {
|
|
super(client, {
|
|
name: 'rock-paper-scissors',
|
|
aliases: ['rps'],
|
|
group: 'games-sp',
|
|
memberName: 'rock-paper-scissors',
|
|
description: 'Play Rock-Paper-Scissors.',
|
|
args: [
|
|
{
|
|
key: 'choice',
|
|
type: 'string',
|
|
parse: choice => choice.toLowerCase()
|
|
}
|
|
]
|
|
});
|
|
}
|
|
|
|
run(msg, { choice }) {
|
|
const response = choices[Math.floor(Math.random() * choices.length)];
|
|
if (choice === 'rock') {
|
|
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.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.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.reply('I win by default, you little cheater.');
|
|
}
|
|
};
|