Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*BOT DISCORD
- *
- * Event - Staff FuzeIII
- * 4 / 01 / 20
- *
- * Developped by Wistaro
- */
- 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 role_quasiwin = "663057045309751296"
- 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"
- const channel_acc = "660083954069536770"
- /* ESCAPE GAME DATA*/
- const code_1 = "1978"
- const code_2 = "guitare"
- const code_3 = "fanatique"
- const code_4 = "google"
- const code_5 = "corsaire"
- const code_6 = "FuzeIII"
- /*Team Stats*/
- let team1_fail;
- let team2_fail;
- let team3_fail;
- let team1_startTime;
- let team2_startTime;
- let team3_startTime;
- let team1_step;
- let team2_step;
- let team3_step;
- client.on('ready', () => {
- client.user.setActivity("YOU! ", {type: "WATCHING"})
- //resetEscapeGame();
- })
- client.on('message', (receivedMessage) => {
- if (receivedMessage.author == client.user) {
- 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)
- console.log("Auteur:"+receivedMessage.author.toString())
- if (primaryCommand == "help") {
- helpCommand(arguments, receivedMessage)
- } else if (primaryCommand == "code"){
- code(arguments, receivedMessage);
- } else if (primaryCommand == "debug") {
- debug(arguments, receivedMessage)
- } else if (primaryCommand == "fail") {
- getFail(arguments, receivedMessage)
- } else if (primaryCommand == "time") {
- elapsedTime(arguments, receivedMessage)
- }else if (primaryCommand == "resetGame") {
- reset(arguments, receivedMessage)
- }else if (primaryCommand == "lisou") {
- lisou(arguments, receivedMessage)
- }else if (primaryCommand == "lead") {
- getLead(arguments, receivedMessage)
- }else {
- receivedMessage.channel.send("T'a écrit une commande qui n'existe pas, gg!")
- }
- }
- function getLead(arguments, receivedMessage) {
- msgStr = "**__Classement actuel des équipes__**\n\n";
- let first;
- let second;
- let third;
- if(team1_step > 0){
- msgStr+="**Team #1:** étape "+team1_step+" et joue depuis "+secondsToDhms(Math.round((Date.now() - team1_startTime)/1000))+"\n"
- }else{
- msgStr+="**L'équipe #1 n'a pas commencée à jouer!**\n"
- }
- if(team2_step > 0){
- msgStr+="**Team #2:** étape "+team2_step+" et joue depuis "+secondsToDhms(Math.round((Date.now() - team2_startTime)/1000))+"\n"
- }else{
- msgStr+="**L'équipe #2 n'a pas commencée à jouer!**\n"
- }
- if(team3_step > 0){
- msgStr+="**Team #3:** étape "+team3_step+" et joue depuis "+secondsToDhms(Math.round((Date.now() - team3_startTime)/1000))+"\n"
- }else{
- msgStr+="**L'équipe #3 n'a pas commencée à jouer!**\n"
- }
- receivedMessage.channel.send(msgStr);
- }
- function lisou(arguments, receivedMessage) {
- receivedMessage.channel.send(getMessageLisou());
- }
- function reset(arguments, receivedMessage) {
- if(receivedMessage.member.roles.has(role_gameMaster)) {
- resetEscapeGame(receivedMessage);
- receivedMessage.channel.send("Jeu remis à 0!");
- }else{
- receivedMessage.channel.send("Tu n'as pas la permission de taper cette commande!");
- }
- }
- function elapsedTime(arguments, receivedMessage) {
- let roleUser = receivedMessage.member.roles;
- if(roleUser.has(role_team1) && team1_step > 0){
- let seconds = Math.round((Date.now() - team1_startTime)/1000)
- let dataTime = secondsToDhms(seconds);
- receivedMessage.channel.send("Ton équipe a démarrée le jeu depuis "+dataTime);
- }else if(roleUser.has(role_team2) && team2_step > 0 ){
- let seconds = Math.round((Date.now() - team2_startTime)/1000)
- let dataTime = secondsToDhms(seconds);
- receivedMessage.channel.send("Ton équipe a démarrée le jeu depuis "+dataTime);
- }else if(roleUser.has(role_team3) && team3_step > 0 ){
- let seconds = Math.round((Date.now() - team3_startTime)/1000)
- let dataTime = secondsToDhms(seconds);
- receivedMessage.channel.send("Ton équipe a démarrée le jeu depuis "+dataTime);
- }else{
- receivedMessage.channel.send("Ton équipe n'a pas commencée à jouer!");
- }
- return
- }
- function getFail(arguments, receivedMessage) {
- let roleUser = receivedMessage.member.roles;
- if(roleUser.has(role_team1)){
- receivedMessage.channel.send("Ton équipe a "+team1_fail+" tentatives ratées de code!");
- }else if(roleUser.has(role_team2)){
- receivedMessage.channel.send("Ton équipe a "+team2_fail+" tentatives ratées de code!");
- }else if(roleUser.has(role_team3)){
- receivedMessage.channel.send("Ton équipe a "+team3_fail+" tentatives ratées de code!");
- }
- return
- }
- function helpCommand(arguments, receivedMessage) {
- client.channels.get(channel_info_team1).send("Votre équipe a "+team1_fail+" tentative ratées de code");("Hey les <@660084050836324383>, y'a "+receivedMessage.author.toString()+" qui a besoin d'aide ici!")
- }
- function debug(arguments, receivedMessage){
- receivedMessage.channel.send("pong");
- }
- function getMessageLisou(){
- let maxMsg = 4;
- let rnd = intAlea(1,maxMsg)
- switch (rnd) {
- case 1:
- return "**Lisou, tu sais ce qu'est un labyrinthe?** \n\n Dans la tête de Lisou: https://file1.science-et-vie.com/var/scienceetvie/storage/images/1/0/0/100118/chaque-arbre-cache-une-foret.jpg"
- break;
- case 2:
- return "**Lisou, tu sais ce qu'est une course d'orientation?** \n\n Dans la tête de Lisou: https://img-4.linternaute.com/ta1--RCE72a3XacSQ8Lx_ahTZGE=/620x/smart/317961a8d0c2475dbbb7a8f28acdf6c2/ccmcms-linternaute/11513893.jpg"
- break;
- case 3:
- return "**Lisou, tu sais ce qu'est un dropper?** \n\n Dans la tête de Lisou: http://boiteries-des-bovins.fr/wp-content/uploads/2017/06/Vache-au-p%C3%A2turage-ligne-de-dos-droite-e1497537711887-800x601.jpg"
- break;
- case 4:
- return "**Lisou, tu sais ce qu'est un jump?** \n\n Dans la tête de Lisou: https://cdn.easycash.fr/img/prod/0/0/3/9/1/1/2/5/5/prod_900x650/gameboy_advance.jpg"
- break;
- case 5:
- return "**Lisou, tu sais ce qu'est une course d'orientation?** \n\n Dans la tête de Lisou: https://img-4.linternaute.com/ta1--RCE72a3XacSQ8Lx_ahTZGE=/620x/smart/317961a8d0c2475dbbb7a8f28acdf6c2/ccmcms-linternaute/11513893.jpg"
- break;
- case 6:
- return "**Lisou, tu sais ce qu'est une course d'orientation?** \n\n Dans la tête de Lisou: https://img-4.linternaute.com/ta1--RCE72a3XacSQ8Lx_ahTZGE=/620x/smart/317961a8d0c2475dbbb7a8f28acdf6c2/ccmcms-linternaute/11513893.jpg"
- break;
- default:
- return "Y'a une erreur dans le bot (désolé Wistaro est nul, c'est pas ma faute)"
- break;
- }
- }
- function giveRoleTeam(role2give, receivedMessage){
- let roleUser = receivedMessage.member.roles;
- let teamRole = ''
- let channelRole = ''
- if(roleUser.has(role_team1)){
- teamRole = role_team1;
- channelInfo = channel_info_team1;
- }else if(roleUser.has(role_team2)){
- teamRole = role_team2;
- channelInfo = channel_info_team2;
- }else if(roleUser.has(role_team3)){
- teamRole = role_team3;
- channelInfo = channel_info_team3;
- }
- let usersWithRole = receivedMessage.guild.roles.get(teamRole).members.map(m=>m.user.id);
- usersWithRole.forEach(element => receivedMessage.guild.fetchMember(element).then(guildMember => {guildMember.addRole(role2give).catch(console.error)} ) );
- return channelInfo;
- }
- function increaseStep(receivedMessage){
- if(receivedMessage.member.roles.has(role_team1)){
- team1_step++;
- }else if(receivedMessage.member.roles.has(role_team2)){
- team2_step++;
- }else if(receivedMessage.member.roles.has(role_team3)){
- team3_step++;
- }
- }
- function resetEscapeGame(receivedMessage){
- team1_fail = 0
- team2_fail = 0
- team3_fail = 0
- team1_startTime = 0;
- team2_startTime = 0;
- team3_startTime = 0;
- team1_step = 0;
- team2_step = 0;
- team3_step = 0;
- /* REMOVE ROLES */
- receivedMessage.guild.roles.get(role_1).members.map(m=>m.user.id).forEach(element => receivedMessage.guild.fetchMember(element).then(guildMember => {guildMember.removeRole(role_1).catch(console.error)} ) );
- receivedMessage.guild.roles.get(role_2).members.map(m=>m.user.id).forEach(element => receivedMessage.guild.fetchMember(element).then(guildMember => {guildMember.removeRole(role_2).catch(console.error)} ) );
- receivedMessage.guild.roles.get(role_3).members.map(m=>m.user.id).forEach(element => receivedMessage.guild.fetchMember(element).then(guildMember => {guildMember.removeRole(role_3).catch(console.error)} ) );
- receivedMessage.guild.roles.get(role_4).members.map(m=>m.user.id).forEach(element => receivedMessage.guild.fetchMember(element).then(guildMember => {guildMember.removeRole(role_4).catch(console.error)} ) );
- receivedMessage.guild.roles.get(role_5).members.map(m=>m.user.id).forEach(element => receivedMessage.guild.fetchMember(element).then(guildMember => {guildMember.removeRole(role_5).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! ");
- let channelInfo = giveRoleTeam(role_1, receivedMessage);
- client.channels.get(channelInfo).send("@everyone Bravo à "+receivedMessage.author.toString()+" qui a trouvé le code de la première épreuve! Vous avez désormais tous accès à l'épreuve suivante! Faites vite, le chronomètre vient de démarrer!");
- if(receivedMessage.member.roles.has(role_team1)){
- team1_startTime = Date.now();
- }else if(receivedMessage.member.roles.has(role_team2)){
- team2_startTime = Date.now();
- }else if(receivedMessage.member.roles.has(role_team3)){
- team3_startTime = Date.now();
- }
- increaseStep(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! ");
- let channelInfo = giveRoleTeam(role_2, receivedMessage);
- client.channels.get(channelInfo).send("@everyone Bravo à "+receivedMessage.author.toString()+" qui a trouvé le code de la seconde épreuve! Vous avez désormais tous accès à l'épreuve suivante!");
- increaseStep(receivedMessage);
- }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! ");
- let channelInfo = giveRoleTeam(role_3, receivedMessage);
- client.channels.get(channelInfo).send("@everyone Bravo à "+receivedMessage.author.toString()+" qui a trouvé le code de la troisième épreuve! Vous avez désormais tous accès à l'épreuve suivante!");
- increaseStep(receivedMessage);
- }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! ");
- let channelInfo = giveRoleTeam(role_4, receivedMessage);
- client.channels.get(channelInfo).send("@everyone Bravo à "+receivedMessage.author.toString()+" qui a trouvé le code de la quatrième épreuve! Vous avez désormais tous accès à l'épreuve suivante!");
- increaseStep(receivedMessage);
- }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! ");
- let channelInfo = giveRoleTeam(role_5, receivedMessage);
- increaseStep(receivedMessage);
- client.channels.get(channelInfo).send("@everyone Bravo à "+receivedMessage.author.toString()+" qui a trouvé le code de la dernière épreuve!");
- }else if(arguments == code_6 && (receivedMessage.member.roles.has(role_5) || receivedMessage.member.roles.has(role_gameMaster) )){
- receivedMessage.channel.send("Bravo, ton équipe et toi avez presque gagné cet évent!!! ");
- let channelInfo = giveRoleTeam(role_quasiwin, receivedMessage);
- increaseStep(receivedMessage);
- client.channels.get(channel_acc).send("@everyone L'équipe de "+receivedMessage.author.toString()+" est sur le point de gagner l'event!");
- }
- else{
- receivedMessage.channel.send("Désolé, ton code est incorrect :( ");
- if(receivedMessage.member.roles.has(role_team1)){
- team1_fail++;
- }else if(receivedMessage.member.roles.has(role_team2)){
- team2_fail++;
- }else if(receivedMessage.member.roles.has(role_team3)){
- team3_fail++;
- }
- }
- console.log(receivedMessage.member);
- }
- }
- function intAlea(min, max)
- {
- return Math.floor(Math.random() * (max - min + 1)) + min;
- }
- function secondsToDhms(seconds) {
- seconds = Number(seconds);
- var h = Math.floor(seconds % (3600*24) / 3600);
- var m = Math.floor(seconds % 3600 / 60);
- var s = Math.floor(seconds % 60);
- var hDisplay = h > 0 ? h + (h == 1 ? " heure, " : " heures, ") : "";
- var mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : "";
- var sDisplay = s > 0 ? s + (s == 1 ? " seconde" : " secondes") : "";
- return hDisplay + mDisplay + sDisplay;
- }
- client.login(bot_token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement