Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. global.Promise = require("bluebird"); // use bluebird instead of native promises
  2. const Eris = require("eris"); // set Eris to eris package
  3. const Jimp = require("jimp"); // set Jimp to jimp package
  4. const config = require("./config.json"); // set config to config file
  5.  
  6. async function init() { // init function
  7.     if(!config.token) { // check if token is in config
  8.         console.error("Token must be set in config.json");
  9.         process.exit(0);
  10.     } else {
  11.         global.bot = new Eris.CommandClient(config.token, { // create bot
  12.             disableEvents: {
  13.                 PRESENCE_UPDATE: true,
  14.                 TYPING_START: true,
  15.                 USER_UPDATE: true,
  16.                 VOICE_STATE_UPDATE: true
  17.             },
  18.             messageLimit: 0,
  19.             defaultImageFormat: "png",
  20.             defaultImageSize: 256
  21.           },{ description: "A test bot made with Eris",
  22.              owner: "somebody",
  23.              prefix: "!"});
  24.  
  25.         bot.once("ready", () => { // establish listener for when bot is ready
  26.             console.log("Bot Started");
  27.             bot.editStatus("online", { name: config.game });
  28.         });
  29.        
  30.         bot.registerCommandAlias("halp", "help"); // Alias !halp to !help
  31.  
  32. //COMMANDS
  33. bot.registerCommand("ping", "Pong!", { // Make a ping command
  34. // Responds with "Pong!" when someone says "!ping"
  35.     description: "Pong!",
  36.     fullDescription: "This command could be used to check if the bot is up. Or entertainment when you're bored."
  37. });
  38.  
  39. bot.registerCommand("pong", ["Pang!", "Peng!", "Ping!", "Pung!"], { // Make a pong command
  40. // Responds with a random version of "Ping!" when someone says "!pong"
  41.     description: "Ping!",
  42.     fullDescription: "This command could also be used to check if the bot is up. Or entertainment when you're bored."
  43. });
  44.  
  45. var echoCommand = bot.registerCommand("echo", (msg, args) => { // Make an echo command
  46.     if(args.length === 0) { // If the user just typed "!echo", say "Invalid input"
  47.         return "Invalid input";
  48.     }
  49.     var text = args.join(" "); // Make a string of the text after the command label
  50.     return text; // Return the generated string
  51. }, {
  52.     description: "Make the bot say something",
  53.     fullDescription: "The bot will echo whatever is after the command label.",
  54.     usage: "<text>"
  55. });
  56.        
  57. //END COMMANDS
  58.         bot.connect(); // connect the bot
  59.     }
  60. }
  61. init(); // call function
  62.  
  63. bot.on("messageCreate", async message => { // establish listener for message
  64.    
  65.     if(message.channel.id === "201990607273590784") { //make sure the bot only responds to images on the verifications channel
  66.     if(message.author.bot) return; // if the user is a bot stop
  67.     //else if(message.channel.guild) return; // if there is a server stop
  68.     let attach = message.attachments[0]; // get message attacments
  69.     if(!attach || !attach.height || !attach.width) { // check if there is an attachment and its a image
  70.         //await message.channel.createMessage("Please send a image of your profile to recieve a role!");
  71.     } else {
  72.         const img = await Jimp.read(attach.url); // read image
  73.         let colorInt = img.getPixelColor(attach.width, Math.floor(attach.height * 2)); // get color of pixel half way down the image and to the right
  74.         let colorRGBA = Jimp.intToRGBA(colorInt); // get RGBA pallet of image
  75.  
  76.         console.log(colorRGBA); // this shouldnt be here oops
  77.         if(colorRGBA.r < 65 && // test colors
  78.             colorRGBA.g > 110 && colorRGBA.g < 130 &&
  79.             colorRGBA.b > 230 && colorRGBA.b < 250 &&
  80.             colorRGBA.a === 255) {
  81.             await bot.addGuildMemberRole(config.serverID, message.author.id, config.roleID); // add role
  82.             message.channel.createMessage("You are on Mystic. You are now verified! please go ahead and introduce yourself in <#324859099340865537> im sure everyone will be happy to say hi :smiley:");
  83.            
  84.             setTimeout(function() {
  85.                 bot.purgeChannel("201990607273590784",-1,message => message.author.id === "321334469439127554")
  86.                 //message.channel.purge(args, message => message.author.id === this.bot.user.id, message.id)
  87.                 console.log("messages deleted");
  88.              },120000);
  89.            
  90.         } else {
  91.             message.channel.createMessage("You are not Mystic :(");
  92.         }
  93.     }
  94. }
  95.     //CHECk MESSAGE CODE#
  96.     //END CHECK CODE
  97. }
  98. )
  99. bot.on("guildMemberAdd", (guild, member) => { // When a member joins a guild
  100.     var response = `Welcome ${member.mention} to ${guild.name} Please get yourself verified by posting a photo of your **Pokemon Trainer Screen** in order to get access to the rest of the discord`;
  101.     // Make a welcome string with the member mention and guild name
  102.    
  103.     setTimeout(function() {
  104.     bot.createMessage(guild.defaultChannel.id, response);
  105.     }, 500);
  106.    
  107.     //change the response for a second message
  108.     var response2 = "if you are unsure what to do just leave a message here and one of the moderators will be able to assist you :smiley:"
  109.    
  110.     //send the second message
  111.    
  112.     setTimeout(function() {
  113.     bot.createMessage(guild.defaultChannel.id, response2);
  114.     }, 1500);
  115.    
  116.     // Send the response in the guild's default channel
  117. });
  118.  
  119. bot.on("guildMemberRemove", (guild, member) => { // When a member leaves a guild
  120.     var response = `Goodbye ${member.user.username} you probably didnt belong here anyway :angry: `;
  121.     // Make a goodbye string with the member mention and guild name
  122.  
  123.     bot.createMessage(guild.defaultChannel.id, response);
  124.     // Send the response in the guild's default channel
  125. });
  126.  
  127. bot.on("guildMemberUpdate", (guild,member) => {
  128.    
  129.     if(member.roles.includes("202001956703567872"))
  130.     {
  131.     console.log(member.username + " verified")
  132.     }    
  133. });
  134.  
  135. function checkMystic()
  136. {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement