Как заставить камень, ножницы, бумагу работать в раздоре. js с реакциями - PullRequest
0 голосов
/ 19 апреля 2020

Я пытаюсь создать камень, ножницы, бумагу для моего разногласия бота в разногласиях. js. Я попытался создать, но в настоящее время он не работает.

Я бы хотел, чтобы смайлики исчезли, как только была сделана реакция, и я не уверен, как это сделать.

module.exports = {
  name: "rps",
  description: "A game of Rock, Paper, Scissors!",
  execute(message) {
    var rps = ["?", "?", "✂️"]
    const m = message.channel.send("Let's play a game of Rock, Paper, Scissors! Please react what you would like to choose with the emojis below!").then((message) => {
      message.react("?");
      message.react("?");
      message.react("✂️");
    });
    const reacted = promptMessage(m, message.author, 30, rps);

    const botChoice = rps[Math.floor(Math.random()*rps.length)];
    const result = getResult(reacted, botChoice);
    m.clearReactions();

    message.channel.send(`You chose ${reacted} and I chose ${botChoice}`);

    function getResult(choice, botChosen) {
      if(choice === "?" && botChoice === "✂️") {
          return message.channel.send("You win! I had fun, let's play again!");
        } else if (choice === "?" && botChoice === "?") {
          return message.channel.send("You win! I had fun, let's play again!");
        } else if (choice === "✂️" && botChoice === "?"){
          return message.channel.send("You win! I had fun, let's play again!");
        } else if (choice === botChosen) {
          return message.channel.send("It's a tie!");
        } else {
          return message.channel.send("You lost! I had fun, let's play again!");
        }
    }
  },
};

1 Ответ

0 голосов
/ 19 апреля 2020

Вы можете удалить все реакции, используя message.reactions.removeAll() (обратите внимание, что для этого требуется MANAGE_MESSAGES). Я рекомендую разместить это на линии после function getResult(choice, botChosen) {

...