├── .gitignore ├── package.json ├── README.md └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "account-generator", 3 | "version": "1.0.0", 4 | "description": "A discord bot you can use to give accounts to your server's members", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/silvanohirtie/account-generator.git" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "bugs": { 17 | "url": "https://github.com/silvanohirtie/account-generator/issues" 18 | }, 19 | "homepage": "https://github.com/silvanohirtie/account-generator#readme", 20 | "dependencies": { 21 | "async": "^3.1.0", 22 | "discord.js": "^11.5.1", 23 | "express": "^4.17.1", 24 | "firstline": "^2.0.2", 25 | "line-reader": "^0.4.0" 26 | } 27 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Account generator 2 | This is the updated version of my first account generator app. 3 | > This is the updated version of my first account generator app. 4 | 5 | 6 | ## 🖥️ Dependencies 7 | - discord.js 8 | - async 9 | - express 10 | - firstline 11 | - line-reader 12 | 13 | ## ⚙️ How does it works? 14 | First of all you need to create a service using "/create SERVICENAME", this will create a SERVICENAME.txt file, you can also create it manually. 15 | Then just add accounts to it manually or with the command "add mail:password SERVICENAME" this will take the first line of SERVICENAME.txt and send it in the user's DM. 16 | In the source code remember to replace "Channel ID" in the if (message.channel.id === "Channel_ID") line with the id of the channel you want to make the bot work in. 17 | 18 | ## Commands 19 | - /create [service name] - it creates a .txt file with the name you choose. The users will now be able to generate an account of that service. 20 | - /add [credentials][service name] - this will add the account you typed, into the .txt file of the service you choose. 21 | - /gen [service name] - this will take the first account of that service and send it into the dms 22 | - /restock [service name] - this will send a notification to all the server saying that the service has been restocked by an admin. 23 | 24 | ## Support 25 | 26 | To get support use: 27 | - Mail: hirtie.silvano@gmail.com 28 | - Discord: Mental#8160 29 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const Discord = require("discord.js"); 2 | const bot = new Discord.Client(); 3 | const prefix = "/"; 4 | var fs = require("fs"); 5 | var lineReader = require("line-reader"); 6 | var async = require("async"); 7 | const firstline = require("firstline"); 8 | const generated = new Set(); 9 | var os = require("os"); 10 | 11 | var express = require('express'); 12 | var app = express(); 13 | 14 | app.set('port', (process.env.PORT || 5000)); 15 | 16 | //For avoidong Heroku $PORT error 17 | app.get('/', function (request, response) { 18 | var result = 'App is running' 19 | response.send(result); 20 | }).listen(app.get('port'), function () { 21 | console.log('App is running, server is listening on port ', app.get('port')); 22 | }); 23 | bot.on("ready", () => { 24 | console.log(`Logged in as ${bot.user.tag}!`); 25 | }); 26 | 27 | bot.on("message", message => { 28 | if (message.channel.id === "Channel_ID") { //This will make the bot work only in that channel 29 | if (message.author.bot) return; 30 | var command = message.content 31 | .toLowerCase() 32 | .slice(prefix.length) 33 | .split(" ")[0]; 34 | 35 | if (command === "test") { 36 | message.channel.send("Test done, bot is working"); 37 | } 38 | 39 | if (command === "gen") { 40 | if (generated.has(message.author.id)) { 41 | message.channel.send( 42 | "Wait 15 minute before generating another account!. - " + 43 | message.author 44 | ); 45 | } else { 46 | let messageArray = message.content.split(" "); 47 | let args = messageArray.slice(1); 48 | if (!args[0]) 49 | return message.reply("Please, specify the service you want!"); 50 | var fs = require("fs"); 51 | const filePath = __dirname + "/" + args[0] + ".txt"; 52 | 53 | fs.readFile(filePath, function (err, data) { 54 | if (!err) { 55 | data = data.toString(); 56 | var position = data.toString().indexOf("\n"); 57 | var firstLine = data.split("\n")[0]; 58 | message.author.send(firstLine); 59 | if (position != -1) { 60 | data = data.substr(position + 1); 61 | fs.writeFile(filePath, data, function (err) { 62 | const embed = { 63 | title: "Account Generated!", 64 | description: "Check your dm for the account's information!", 65 | color: 8519796, 66 | timestamp: "2019-04-04T14:16:26.398Z", 67 | footer: { 68 | icon_url: 69 | "https://cdn.discordapp.com/avatars/530778425540083723/7a05e4dd16825d47b6cdfb02b92d26a5.png", 70 | text: "Buy discord accounts from Mental#8106" 71 | }, 72 | thumbnail: { 73 | url: 74 | "http://www.compartosanita.it/wp-content/uploads/2019/02/right.png" 75 | }, 76 | author: { 77 | name: "Account Generator", 78 | url: "https://discordapp.com", 79 | icon_url: bot.displayAvatarURL 80 | }, 81 | fields: [] 82 | }; 83 | message.channel.send({ embed }); 84 | generated.add(message.author.id); 85 | setTimeout(() => { 86 | // Removes the user from the set after a minute 87 | generated.delete(message.author.id); 88 | }, 150000); 89 | if (err) { 90 | console.log(err); 91 | } 92 | }); 93 | } else { 94 | message.channel.send( 95 | "Sorry, there isn't any account available for that service!" 96 | ); 97 | } 98 | } else { 99 | message.channel.send( 100 | "Sorry, that service doesn't exists on our database" 101 | ); 102 | } 103 | }); 104 | } 105 | } 106 | else 107 | if (command === "stats") { 108 | 109 | message.channel.send(`Total users: ${bot.users.size}`) 110 | } 111 | 112 | if (command === "add") { 113 | if (!message.member.hasPermission("ADMINISTRATOR")) 114 | return message.reply("Sorry, you can't do it, you are not an admin!"); 115 | var fs = require("fs"); 116 | let messageArray = message.content.split(" "); 117 | let args = messageArray.slice(1); 118 | var account = args[0] 119 | var service = args[1] 120 | const filePath = __dirname + "/" + args[1] + ".txt"; 121 | fs.appendFile(filePath, os.EOL + args[0], function (err) { 122 | if (err) return console.log(err); 123 | message.channel.send("Done!") 124 | }); 125 | 126 | 127 | } 128 | if (command === "create") { 129 | if (!message.member.hasPermission("ADMINISTRATOR")) 130 | return message.reply("Sorry, you can't do it, you are not an admin!"); 131 | var fs = require("fs"); 132 | let messageArray = message.content.split(" "); 133 | let args = messageArray.slice(1); 134 | const filePath = __dirname + "/" + args[0] + ".txt"; 135 | fs.writeFile(filePath, 'first:first', function (err) { 136 | if (err) throw err; 137 | message.channel.send("Done!") 138 | }); 139 | } 140 | if (command === "restock") { 141 | let messageArray = message.content.split(" "); 142 | let args = messageArray.slice(1); 143 | if (!message.member.hasPermission("ADMINISTRATOR")) 144 | return message.reply("Sorry, you can't do it, you are not an admin!"); 145 | if (!args[0]) 146 | return message.reply( 147 | "Please, specify the service you want to restock!" 148 | ); 149 | message.channel.send( 150 | "@everyone " + 151 | "**" + 152 | args[0] + 153 | "**" + 154 | " has been restocked by " + 155 | "<@" + 156 | message.author.id + 157 | ">" 158 | ); 159 | } 160 | } 161 | }); 162 | 163 | bot.login("Token"); --------------------------------------------------------------------------------