Files
gestion-perso/commands/game/pfc.ts
T
2024-02-26 11:20:08 +01:00

43 lines
1.6 KiB
TypeScript

import { Message } from "discord.js";
const choices = ["pierre", "papier", "ciseaux"];
module.exports = {
aliases: ['pierre-papier-ciseaux', 'shifumi', 'pierrepapierciseaux', 'rockpaperscissors', 'rock-paper-scissors'],
description: 'Jouer à pierre-papier-ciseaux',
emote: '✊',
utilisation: '',
async execute(message: Message, args: string[]) {
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}.`);
}
}
},
};