Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global.Promise = require("bluebird"); // use bluebird instead of native promises
- const Eris = require("eris"); // set Eris to eris package
- const Jimp = require("jimp"); // set Jimp to jimp package
- const config = require("./config.json"); // set config to config file
- async function init() { // init function
- if(!config.token) { // check if token is in config
- console.error("Token must be set in config.json");
- process.exit(0);
- } else {
- global.bot = new Eris.CommandClient(config.token, { // create bot
- disableEvents: {
- PRESENCE_UPDATE: true,
- TYPING_START: true,
- USER_UPDATE: true,
- VOICE_STATE_UPDATE: true
- },
- messageLimit: 0,
- defaultImageFormat: "png",
- defaultImageSize: 256
- },{ description: "A test bot made with Eris",
- owner: "somebody",
- prefix: "!"});
- bot.once("ready", () => { // establish listener for when bot is ready
- console.log("Bot Started");
- bot.editStatus("online", { name: config.game });
- });
- bot.registerCommandAlias("halp", "help"); // Alias !halp to !help
- //COMMANDS
- bot.registerCommand("ping", "Pong!", { // Make a ping command
- // Responds with "Pong!" when someone says "!ping"
- description: "Pong!",
- fullDescription: "This command could be used to check if the bot is up. Or entertainment when you're bored."
- });
- bot.registerCommand("pong", ["Pang!", "Peng!", "Ping!", "Pung!"], { // Make a pong command
- // Responds with a random version of "Ping!" when someone says "!pong"
- description: "Ping!",
- fullDescription: "This command could also be used to check if the bot is up. Or entertainment when you're bored."
- });
- var echoCommand = bot.registerCommand("echo", (msg, args) => { // Make an echo command
- if(args.length === 0) { // If the user just typed "!echo", say "Invalid input"
- return "Invalid input";
- }
- var text = args.join(" "); // Make a string of the text after the command label
- return text; // Return the generated string
- }, {
- description: "Make the bot say something",
- fullDescription: "The bot will echo whatever is after the command label.",
- usage: "<text>"
- });
- //END COMMANDS
- bot.connect(); // connect the bot
- }
- }
- init(); // call function
- bot.on("messageCreate", async message => { // establish listener for message
- if(message.channel.id === "201990607273590784") { //make sure the bot only responds to images on the verifications channel
- if(message.author.bot) return; // if the user is a bot stop
- //else if(message.channel.guild) return; // if there is a server stop
- let attach = message.attachments[0]; // get message attacments
- if(!attach || !attach.height || !attach.width) { // check if there is an attachment and its a image
- //await message.channel.createMessage("Please send a image of your profile to recieve a role!");
- } else {
- const img = await Jimp.read(attach.url); // read image
- let colorInt = img.getPixelColor(attach.width, Math.floor(attach.height * 2)); // get color of pixel half way down the image and to the right
- let colorRGBA = Jimp.intToRGBA(colorInt); // get RGBA pallet of image
- console.log(colorRGBA); // this shouldnt be here oops
- if(colorRGBA.r < 65 && // test colors
- colorRGBA.g > 110 && colorRGBA.g < 130 &&
- colorRGBA.b > 230 && colorRGBA.b < 250 &&
- colorRGBA.a === 255) {
- await bot.addGuildMemberRole(config.serverID, message.author.id, config.roleID); // add role
- 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:");
- setTimeout(function() {
- bot.purgeChannel("201990607273590784",-1,message => message.author.id === "321334469439127554")
- //message.channel.purge(args, message => message.author.id === this.bot.user.id, message.id)
- console.log("messages deleted");
- },120000);
- } else {
- message.channel.createMessage("You are not Mystic :(");
- }
- }
- }
- //CHECk MESSAGE CODE#
- //END CHECK CODE
- }
- )
- bot.on("guildMemberAdd", (guild, member) => { // When a member joins a guild
- 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`;
- // Make a welcome string with the member mention and guild name
- setTimeout(function() {
- bot.createMessage(guild.defaultChannel.id, response);
- }, 500);
- //change the response for a second message
- 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:"
- //send the second message
- setTimeout(function() {
- bot.createMessage(guild.defaultChannel.id, response2);
- }, 1500);
- // Send the response in the guild's default channel
- });
- bot.on("guildMemberRemove", (guild, member) => { // When a member leaves a guild
- var response = `Goodbye ${member.user.username} you probably didnt belong here anyway :angry: `;
- // Make a goodbye string with the member mention and guild name
- bot.createMessage(guild.defaultChannel.id, response);
- // Send the response in the guild's default channel
- });
- bot.on("guildMemberUpdate", (guild,member) => {
- if(member.roles.includes("202001956703567872"))
- {
- console.log(member.username + " verified")
- }
- });
- function checkMystic()
- {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement