Files
xiao/commands/games-sp/rock-paper-scissors.js
T
2024-05-21 21:02:12 -04:00

41 lines
1.3 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',
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.');
}
};