Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js')
- const client = new Discord.Client()
- const bot_token = ""
- /* SERVER DISCORD DATA */
- const role_1 = "660517987530309655" //role for step 1
- const role_2 = "660518119114014740" //role for step 2
- const role_3 = "660518155361189938" //role for step 3
- const role_4 = "660518187154276372" //role for step 4
- const role_5 = "660518225553129492"//role for step 5
- const role_team1 = "660508218153238550" //team 1 role
- const role_team2 = "660508242748899363"; //team 2 role
- const role_team3 = "660508270838022144"; //team 3 role
- const role_gameMaster = "660084050836324383";
- const channel_1 = "660518374669025290"
- const channel_2 = "660518433594671152"
- const channel_3 = "660518475281727519"
- const channel_4 = "660518520328814594"
- const channel_5 = "660518568827551775"
- const channel_com_team1 = "660508909408092181"
- const channel_com_team2 = "660508987867004958"
- const channel_com_team3 = "660509010201411615"
- const channel_info_team1 = "660529335240884224"
- const channel_info_team2 = "660529447610351637"
- const channel_info_team3 = "660529499502542908"
- /* ESCAPE GAME DATA*/
- const code_1 = "ep1"
- const code_2 = "TOTO2"
- const code_3 = "TOTO3"
- const code_4 = "TOTO4"
- const code_5 = "TOTO5"
- client.on('ready', () => {
- client.user.setActivity("YOU! ", {type: "WATCHING"})
- })
- client.on('message', (receivedMessage) => {
- if (receivedMessage.author == client.user) { // Prevent bot from responding to its own messages
- return
- }
- if (receivedMessage.content.startsWith("!")) {
- processCommand(receivedMessage)
- }
- })
- function processCommand(receivedMessage) {
- let fullCommand = receivedMessage.content.substr(1)
- let splitCommand = fullCommand.split(" ")
- let primaryCommand = splitCommand[0]
- let arguments = splitCommand.slice(1)
- console.log("Command received: " + primaryCommand)
- console.log("Arguments: " + arguments)
- if (primaryCommand == "help") {
- helpCommand(arguments, receivedMessage)
- } else if (primaryCommand == "multiply") {
- multiplyCommand(arguments, receivedMessage)
- } else if (primaryCommand == "code"){
- code(arguments, receivedMessage);
- } else if (primaryCommand == "debug")
- debug(arguments, receivedMessage)
- else {
- receivedMessage.channel.send("T'a écrit une commande qui n'existe pas, gg!")
- }
- }
- function helpCommand(arguments, receivedMessage) {
- receivedMessage.channel.send("Hey les <@660084050836324383>, y'a "+receivedMessage.author.toString()+" qui a besoin d'aide ici!")
- }
- function debug(arguments, receivedMessage){
- usersWithRole = receivedMessage.guild.roles.get(role_team1).members.map(m=>m.members);
- console.log("DATA:"+usersWithRole);
- usersWithRole.forEach(element => element);
- // receivedMessage.channel.send(usersWithRole);
- }
- function giveRoleTeam(role2give, teamRole, receivedMessage){
- usersWithRole = receivedMessage.guild.roles.get(teamRole).members.map(m=>m.user.id);
- usersWithRole.forEach(element => guild.fetchMember(client.fetchUser(element)).member.addRole(role2give).catch(console.error))
- }
- function code(arguments, receivedMessage){
- if (arguments.length < 1) {
- receivedMessage.channel.send("Vous n'avez pas donné de code à tester! ")
- return
- }else{
- 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) )){
- receivedMessage.channel.send("Bravo, tu as remporté la première épreuve! ");
- receivedMessage.member.addRole(role_1).catch(console.error);
- client.channels.get(channel_info_team1).send("Bravo à "+receivedMessage.author.toString()+" qui a trouvé le code de la première épreuve!");
- giveRoleTeam(role_1, role_team1, receivedMessage);
- }else if(arguments == code_2 && (receivedMessage.member.roles.has(role_1) || receivedMessage.member.roles.has(role_gameMaster) )){
- receivedMessage.channel.send("Bravo, tu as remporté la seconde épreuve! ");
- receivedMessage.member.addRole(role_2).catch(console.error);
- }else if(arguments == code_3 && (receivedMessage.member.roles.has(role_2) || receivedMessage.member.roles.has(role_gameMaster) )){
- receivedMessage.channel.send("Bravo, tu as remporté la troisième épreuve! ");
- receivedMessage.member.addRole(role_2).catch(console.error);
- }else if(arguments == code_4 && (receivedMessage.member.roles.has(role_3) || receivedMessage.member.roles.has(role_gameMaster) )){
- receivedMessage.channel.send("Bravo, tu as remporté la quatrième épreuve! ");
- receivedMessage.member.addRole(role_3).catch(console.error);
- }else if(arguments == code_5 && (receivedMessage.member.roles.has(role_4) || receivedMessage.member.roles.has(role_gameMaster) )){
- receivedMessage.channel.send("Bravo, tu as remporté la dernière épreuve! ");
- receivedMessage.member.addRole(role_5).catch(console.error);
- }
- else{
- receivedMessage.channel.send("Désolé, ton code est incorrect :( ");
- }
- console.log(receivedMessage.member);
- }
- }
- client.login(bot_token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement