gaber-elsayed

Untitled

Mar 9th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. client.on('message' , message => {
  2. if(message.author.bot) return;
  3. if(message.content.startsWith(prefix + "xo")) {
  4. let array_of_mentions = message.mentions.users.array();
  5. let symbols = [':o:', ':heavy_multiplication_x:']
  6. var grid_message;
  7.  
  8. if (array_of_mentions.length == 1 || array_of_mentions.length == 2) {
  9. let random1 = Math.floor(Math.random() * (1 - 0 + 1)) + 0;
  10. let random2 = Math.abs(random1 - 1);
  11. if (array_of_mentions.length == 1) {
  12. random1 = 0;
  13. random2 = 0;
  14. }
  15. var player1_id = message.author.id
  16. let player2_id = array_of_mentions[random2].id;
  17. var turn_id = player1_id;
  18. var symbol = symbols[0];
  19. let initial_message = `اللعبة بين اللاعبين التاليين <@${player1_id}> and <@${player2_id}>!`;
  20. if (player1_id == player2_id) {
  21. initial_message += '\n_(لقد خسرت, العب مع نفسك :joy:)_'
  22. }
  23. message.channel.send(`Xo ${initial_message}`)
  24. .then(console.log("Successful tictactoe introduction"))
  25. .catch(console.error);
  26. message.channel.send(':one::two::three:' + '\n' +
  27. ':four::five::six:' + '\n' +
  28. ':seven::eight::nine:')
  29. .then((new_message) => {
  30. grid_message = new_message;
  31. })
  32. .then(console.log("Successful tictactoe game initialization"))
  33. .catch(console.error);
  34. message.channel.send('Loading... Please wait for the :ok: reaction.')
  35. .then(async (new_message) => {
  36. await new_message.react('1⃣');
  37. await new_message.react('2⃣');
  38. await new_message.react('3⃣');
  39. await new_message.react('4⃣');
  40. await new_message.react('5⃣');
  41. await new_message.react('6⃣');
  42. await new_message.react('7⃣');
  43. await new_message.react('8⃣');
  44. await new_message.react('9⃣');
  45. await new_message.react('🆗');
  46. await new_message.edit(`It\'s <@${turn_id}>\'s اشتغل! الرمز هو ${symbol}`)
  47. .then((new_new_message) => {
  48. require('./xo.js')(client, message, new_new_message, player1_id, player2_id, turn_id, symbol, symbols, grid_message);
  49. })
  50. .then(console.log("Successful tictactoe listeprefix initialization"))
  51. .catch(console.error);
  52. })
  53. .then(console.log("Successful tictactoe react initialization"))
  54. .catch(console.error);
  55. }
  56. else {
  57. message.channel.send(`جرب *xo @uesr`)
  58. .then(console.log("Successful error reply"))
  59. .catch(console.error);
  60. }
  61. }
  62. });
Add Comment
Please, Sign In to add comment