Advertisement
Wistaro

WistaBot

Dec 28th, 2019
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require('discord.js')
  2. const client = new Discord.Client()
  3. const bot_token = ""
  4.  
  5. /* SERVER DISCORD DATA */
  6. const role_1 = "660517987530309655" //role for step 1
  7. const role_2 = "660518119114014740" //role for step 2
  8. const role_3 = "660518155361189938" //role for step 3
  9. const role_4 = "660518187154276372" //role for step 4
  10. const role_5 = "660518225553129492"//role for step 5
  11.  
  12. const role_team1 = "660508218153238550" //team 1 role
  13. const role_team2 = "660508242748899363"; //team 2 role
  14. const role_team3 = "660508270838022144"; //team 3 role
  15. const role_gameMaster = "660084050836324383";
  16.  
  17. const channel_1 = "660518374669025290"
  18. const channel_2 = "660518433594671152"
  19. const channel_3 = "660518475281727519"
  20. const channel_4 = "660518520328814594"
  21. const channel_5 = "660518568827551775"
  22.  
  23. const channel_com_team1 = "660508909408092181"
  24. const channel_com_team2 = "660508987867004958"
  25. const channel_com_team3 = "660509010201411615"
  26.  
  27. const channel_info_team1 = "660529335240884224"
  28. const channel_info_team2 = "660529447610351637"
  29. const channel_info_team3 = "660529499502542908"
  30.  
  31. /* ESCAPE GAME DATA*/
  32.  
  33. const code_1 = "ep1"
  34. const code_2 = "TOTO2"
  35. const code_3 = "TOTO3"
  36. const code_4 = "TOTO4"
  37. const code_5 = "TOTO5"
  38.  
  39.  
  40. client.on('ready', () => {
  41.      client.user.setActivity("YOU! ", {type: "WATCHING"})
  42. })
  43.  
  44. client.on('message', (receivedMessage) => {
  45.     if (receivedMessage.author == client.user) { // Prevent bot from responding to its own messages
  46.         return
  47.     }
  48.    
  49.     if (receivedMessage.content.startsWith("!")) {
  50.         processCommand(receivedMessage)
  51.     }
  52. })
  53.  
  54. function processCommand(receivedMessage) {
  55.     let fullCommand = receivedMessage.content.substr(1)
  56.     let splitCommand = fullCommand.split(" ")
  57.     let primaryCommand = splitCommand[0]
  58.     let arguments = splitCommand.slice(1)
  59.  
  60.     console.log("Command received: " + primaryCommand)
  61.     console.log("Arguments: " + arguments)
  62.  
  63.     if (primaryCommand == "help") {
  64.         helpCommand(arguments, receivedMessage)
  65.     } else if (primaryCommand == "multiply") {
  66.         multiplyCommand(arguments, receivedMessage)
  67.     } else if (primaryCommand == "code"){
  68.         code(arguments, receivedMessage);
  69.     } else if (primaryCommand == "debug")
  70.         debug(arguments, receivedMessage)
  71.     else {
  72.         receivedMessage.channel.send("T'a écrit une commande qui n'existe pas, gg!")
  73.     }
  74. }
  75.  
  76. function helpCommand(arguments, receivedMessage) {
  77.     receivedMessage.channel.send("Hey les <@660084050836324383>, y'a "+receivedMessage.author.toString()+" qui a besoin d'aide ici!")
  78. }
  79.  
  80.  
  81. function debug(arguments, receivedMessage){
  82.  
  83.     usersWithRole = receivedMessage.guild.roles.get(role_team1).members.map(m=>m.members);
  84.     console.log("DATA:"+usersWithRole);
  85.  
  86.     usersWithRole.forEach(element => element);
  87.  
  88.    // receivedMessage.channel.send(usersWithRole);
  89. }
  90.  
  91. function giveRoleTeam(role2give, teamRole, receivedMessage){
  92.     usersWithRole = receivedMessage.guild.roles.get(teamRole).members.map(m=>m.user.id);
  93.     usersWithRole.forEach(element => guild.fetchMember(client.fetchUser(element)).member.addRole(role2give).catch(console.error))
  94. }
  95.  
  96. function code(arguments, receivedMessage){
  97.     if (arguments.length < 1) {
  98.         receivedMessage.channel.send("Vous n'avez pas donné de code à tester! ")
  99.         return
  100.     }else{
  101.         if(arguments == code_1 && (receivedMessage.member.roles.has(role_team1)  ||  receivedMessage.member.roles.has(role_team2) || receivedMessage.member.roles.has(role_team3) || receivedMessage.member.roles.has(role_gameMaster) )){
  102.             receivedMessage.channel.send("Bravo, tu as remporté la première épreuve! ");
  103.             receivedMessage.member.addRole(role_1).catch(console.error);  
  104.  
  105.             client.channels.get(channel_info_team1).send("Bravo à "+receivedMessage.author.toString()+" qui a trouvé le code de la première épreuve!");
  106.  
  107.             giveRoleTeam(role_1, role_team1, receivedMessage);
  108.  
  109.         }else if(arguments == code_2 && (receivedMessage.member.roles.has(role_1)  ||  receivedMessage.member.roles.has(role_gameMaster) )){
  110.             receivedMessage.channel.send("Bravo, tu as remporté la seconde épreuve! ");
  111.             receivedMessage.member.addRole(role_2).catch(console.error);
  112.  
  113.         }else if(arguments == code_3 && (receivedMessage.member.roles.has(role_2)  ||  receivedMessage.member.roles.has(role_gameMaster) )){
  114.             receivedMessage.channel.send("Bravo, tu as remporté la troisième épreuve! ");
  115.             receivedMessage.member.addRole(role_2).catch(console.error);  
  116.  
  117.         }else if(arguments == code_4 && (receivedMessage.member.roles.has(role_3)  ||  receivedMessage.member.roles.has(role_gameMaster) )){
  118.             receivedMessage.channel.send("Bravo, tu as remporté la quatrième épreuve! ");
  119.             receivedMessage.member.addRole(role_3).catch(console.error);  
  120.  
  121.         }else if(arguments == code_5 && (receivedMessage.member.roles.has(role_4)  ||  receivedMessage.member.roles.has(role_gameMaster) )){
  122.             receivedMessage.channel.send("Bravo, tu as remporté la dernière épreuve! ");
  123.             receivedMessage.member.addRole(role_5).catch(console.error);  
  124.         }
  125.  
  126.        
  127.        
  128.         else{
  129.             receivedMessage.channel.send("Désolé, ton code est incorrect :( ");
  130.         }
  131.        
  132.           console.log(receivedMessage.member);
  133.     }
  134. }
  135.  
  136. client.login(bot_token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement