Files
gestion/commands/game/pfc.js
T
2024-02-17 13:33:46 +01:00

44 lines
1.6 KiB
JavaScript

const choices = ["pierre", "papier", "ciseaux"];
module.exports = {
name: 'pfc',
aliases: ['pierre-papier-ciseaux', 'shifumi', 'pierrepapierciseaux', 'rockpaperscissors', 'rock-paper-scissors'],
description: 'Jouer à pierre-papier-ciseaux',
emote: '✊',
utilisation: 'pfc',
category: 'game',
async execute(message, args) {
const userChoice = args[0];
const botChoice = choices[Math.floor(Math.random() * choices.length)];
if (!choices.includes(userChoice)) {
return message.reply("Veuillez choisir pierre, papier ou ciseaux.");
}
if (userChoice === botChoice) {
return message.reply("Égalité!");
}
switch (userChoice) {
case "pierre":
if (botChoice === "ciseaux") {
return message.reply(`Vous avez gagné! Le bot a choisi ${botChoice}.`);
} else {
return message.reply(`Vous avez perdu. Le bot a choisi ${botChoice}.`);
}
case "papier":
if (botChoice === "pierre") {
return message.reply(`Vous avez gagné! Le bot a choisi ${botChoice}.`);
} else {
return message.reply(`Vous avez perdu. Le bot a choisi ${botChoice}.`);
}
case "ciseaux":
if (botChoice === "papier") {
return message.reply(`Vous avez gagné! Le bot a choisi ${botChoice}.`);
} else {
return message.reply(`Vous avez perdu. Le bot a choisi ${botChoice}.`);
}
}
},
};