ASKARM

captcha 1/2

Jun 3rd, 2020
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bot.on("message", async function(message) {
  2.   if (message.content == prefix + "genCaptcha") {
  3.     var { text, image } = await createCaptcha();
  4.     message.channel.send(
  5.       text,
  6.       new discord.MessageAttachment(image, "captcha.png")
  7.     );
  8.   }
  9. });
  10.  
  11. const randomPuppy = require("random-puppy");
  12.  
  13. const createCaptcha = require("./captcha.js");
  14.  
  15. bot.on("ready", () => {
  16.   console.log(`${bot.user.tag} has logged in.`);
  17. });
  18.  
  19. bot.on("guildMemberAdd", async member => {
  20.   var captcha = await createCaptcha();
  21.   try {
  22.     var attachment = new discord.MessageAttachment(
  23.       captcha.image,
  24.       "captcha.png"
  25.     );
  26.     await bot.channels
  27.       .fetch("l'id de votre bot")
  28.       .then(function(ch) {
  29.         ch.send(
  30.           "Hello, <@" +
  31.             member.id +
  32.             ">. In order to access this server, you need to solve a quick captcha. You have 5 minutes to do it before you're kicked. ",
  33.           attachment
  34.         );
  35.       })
  36.       .catch(function(Err) {
  37.         console.error(Err);
  38.       });
  39.     try {
  40.       const filter = m => {
  41.         if (m.author.bot) return;
  42.         if (m.author.id === member.id && m.content === captcha.text)
  43.           return true;
  44.         else {
  45.           m.channel.send("You entered the captcha incorrectly.");
  46.           return false;
  47.         }
  48.       };
  49.       const response = await bot.channels
  50.         .fetch("l'id de votre salon")
  51.         .then(async function(chan) {
  52.           response = chan
  53.             .awaitMessages(filter, { max: 1, time: 300000, errors: ["time"] })
  54.             .then(async function(response) {
  55.               if (response) {
  56.                 await member.send("You have verified yourself!");
  57.                 await member.roles.add("l'id du rôle qie vous voulez mettre à la personne");
  58.               }
  59.             })
  60.             .catch(function(error) {
  61.               console.error(error);
  62.             });
  63.         })
  64.         .catch(function(Err) {
  65.           console.error(Err);
  66.         });
  67.     } catch (err) {
  68.       console.log(err);
  69.       await member.send("You did not solve the captcha correctly on time.");
  70.       await member.kick();
  71.     }
  72.   } catch (err) {
  73.     console.log(err);
  74.   }
  75. });
  76.  
  77. module.exports.run = async (bot, message, args, prefix, logs) => {
  78.   //Le code suivant sera ici !
  79. };
  80. module.exports.command = {
  81.   name: "generate_image",
  82.   aliases: ["image"],
  83.   permission: "none",
  84.   description: "Génère une image avec un texte.",
  85.   usage: "image <langage> <text>",
  86.   args: true,
  87.   args_min: 3,
  88.   need_logs: false,
  89.   category: "INFORMATION",
  90.   enabled: true
  91. };
  92. const canvas = require("canvas");
  93. const ctx = canvas.getContext("2d");
  94. ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
  95. ctx.strokeStyle = "#161b28";
  96. ctx.strokeRect(0, 0, canvas.width, canvas.height);
  97. ctx.font = "70px sans-serif";
  98. ctx.fillStyle = "#ffffff";
  99. ctx.fillText(`${titre}`, 50, 40);
  100. ctx.beginPath();
  101. const attachment = new discord.Attachment(canvas.toBuffer(), 'custom__image.png');
  102.  
  103. message.channel.send('Test', attachment);
  104.  
  105. // conection
  106. bot.login("NjcwNjk2Nzc3MDgyNzMyNTQ1.XiyJeg.O-RilQvDS6Ov7ZPvBI2Goo7wTRE");
  107.  
  108. Object.defineProperty(Array.prototype, "flat", {
  109.   value: function(depth = 1) {
  110.     return this.reduce(function(flat, toFlatten) {
  111.       return flat.concat(
  112.         Array.isArray(toFlatten) && depth > 1
  113.           ? toFlatten.flat(depth - 1)
  114.           : toFlatten
  115.       );
  116.     }, []);
  117.   }
  118. });
  119. https://pastebin.com/aW7H5d7c captcha 2/2
Add Comment
Please, Sign In to add comment