mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-16 23:57:48 +02:00
Add Game
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
const choices = ["pierre", "papier", "ciseaux"];
|
||||
|
||||
module.exports = {
|
||||
name: 'pfc',
|
||||
description: 'Jouer à pierre-papier-ciseaux',
|
||||
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}.`);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user