├── README.md ├── commands └── gen.js ├── config.json ├── index.js └── stock └── Put somthing here.txt /README.md: -------------------------------------------------------------------------------- 1 | # Discord-account-generator 2 | ## Priview 3 | ![p](https://i.imgur.com/UcmpIVf.gif) 4 | ## Installion 5 | Install packages: `npm install` 6 | 7 | ### Configuration file 8 | Before you try to start the bot, you need to fill the `config.json` file. 9 | ```json 10 | { 11 | "token": "", 12 | "prefix": "", 13 | "genChannel": "", 14 | "genCooldown": "", 15 | "color": { 16 | "green": "0x43B581", 17 | "yellow": "0xFAA61A", 18 | "red": "0xF04747", 19 | "default": "0x7289DA" 20 | } 21 | } 22 | ``` 23 | - `token`: Your bot's token 24 | - `prefix`: Your prefix for executing commands (max 10 characters) 25 | - `genChannel`: Target channel for `gen` command 26 | - `genCooldown`: Time between two `gen` command *(use millisec)* 27 | 28 | You can change the `green`, `yellow`, `red` and `default` colors. 29 | 30 | ## only for carter or other 31 | 32 | npm install 33 | 34 | ![r](https://i.imgur.com/HxbLhgJ.gif) 35 | 36 | and node . on cmd 37 | 38 | ## 🛠 Views and Followers 39 | 40 | 41 | 42 | GitHub Badge 43 | -------------------------------------------------------------------------------- /commands/gen.js: -------------------------------------------------------------------------------- 1 | // npmjs packages 2 | const Discord = require('discord.js'); 3 | const fs = require('fs'); 4 | 5 | // configuration 6 | const config = require('../config.json'); 7 | 8 | // collections 9 | const generated = new Set(); 10 | 11 | // export command 12 | module.exports = { 13 | 14 | // command name 15 | name: 'gen', 16 | 17 | // command description 18 | description: 'Generate a specified service, if stocked.', 19 | 20 | // command 21 | execute(message) { 22 | 23 | // if gen channel 24 | if (message.channel.id === config.genChannel) { 25 | 26 | // if generated before 27 | if (generated.has(message.author.id)) { 28 | 29 | // send message to channel 30 | message.channel.send( 31 | new Discord.MessageEmbed() 32 | .setColor(color.red) 33 | .setTitle('Cooldown') 34 | .setDescription('Please wait before executing another command!') 35 | .setFooter(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 64 })) 36 | .setTimestamp() 37 | ); 38 | 39 | // cancel 40 | return; 41 | 42 | // if not generated before 43 | } else { 44 | 45 | // split message content 46 | const messageArray = message.content.split(' '); 47 | 48 | // args 49 | const args = messageArray.slice(1); 50 | 51 | // if the service is missing 52 | if (!args[0]) { 53 | 54 | // send message to channel 55 | message.channel.send( 56 | 57 | // embed 58 | new Discord.MessageEmbed() 59 | .setColor(config.color.red) 60 | .setTitle('Missing parameters') 61 | .setDescription('You need to give a service name!') 62 | .setFooter(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 64 })) 63 | .setTimestamp() 64 | ); 65 | 66 | // cancel 67 | return; 68 | }; 69 | 70 | // stock files path 71 | const filePath = `${__dirname}/../stock/${args[0]}.txt`; 72 | 73 | // read the file 74 | fs.readFile(filePath, function (error, data) { 75 | 76 | // if no error 77 | if (!error) { 78 | 79 | // text file content to string 80 | data = data.toString(); 81 | 82 | // find position 83 | const position = data.toString().indexOf('\n'); 84 | 85 | // find first line 86 | const firstLine = data.split('\n')[0]; 87 | 88 | // if cannot find first line 89 | if (position === -1) { 90 | 91 | // send message to channel 92 | message.channel.send( 93 | 94 | // embed 95 | new Discord.MessageEmbed() 96 | .setColor(config.color.red) 97 | .setTitle('Gen error!') 98 | .setDescription(`I do not find the \`${args[0]}\` service in my stock!`) 99 | .setFooter(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 64 })) 100 | .setTimestamp() 101 | ); 102 | 103 | // cancel 104 | return; 105 | }; 106 | 107 | // send the embed and the copy-paste to the message author 108 | message.author.send( 109 | 110 | //embed 111 | new Discord.MessageEmbed() 112 | .setColor(config.color.green) 113 | .setTitle('Generated account') 114 | .addField('Service', `${args[0]}`) 115 | .addField('Account/Data', `\`\`\`${firstLine}\`\`\``) 116 | .setTimestamp() 117 | ).then(message.author.send('Here is your copy+paste:')).then(message.author.send(`\`${firstLine}\``)); 118 | 119 | // if the service generated successful (position) 120 | if (position !== -1) { 121 | 122 | // text file to string and change position 123 | data = data.substr(position + 1); 124 | 125 | // write file 126 | fs.writeFile(filePath, data, function (error) { 127 | 128 | // send message to channel 129 | message.channel.send( 130 | 131 | // embed 132 | new Discord.MessageEmbed() 133 | .setColor(config.color.green) 134 | .setTitle('Account generated!') 135 | .setDescription(`Check your DMs ${message.author}! *If you do not recieved the message, please unlock your DMs!*`) 136 | .setFooter(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 64 })) 137 | .setTimestamp() 138 | ); 139 | 140 | // add the message author to cooldown collection 141 | generated.add(message.author.id); 142 | 143 | // set cooldown (in millisec) 144 | setTimeout(() => { 145 | 146 | // remove the message author from cooldown collection after timeout 147 | generated.delete(message.author.id); 148 | }, config.genCooldown); 149 | 150 | // if error 151 | if (error) { 152 | 153 | // write to console 154 | console.log(error); 155 | }; 156 | }); 157 | 158 | // if no lines 159 | } else { 160 | 161 | // send message to channel 162 | message.channel.send( 163 | 164 | // embed 165 | new Discord.MessageEmbed() 166 | .setColor(config.color.red) 167 | .setTitle('Gen error!') 168 | .setDescription(`I do not find any accounts in \`${args[0]}\` service!`) 169 | .setFooter(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 64 })) 170 | .setTimestamp() 171 | ); 172 | 173 | // cancel 174 | return; 175 | }; 176 | 177 | // if error 178 | } else { 179 | 180 | // send message to channel 181 | message.channel.send( 182 | 183 | // embed 184 | new Discord.MessageEmbed() 185 | .setColor(config.color.red) 186 | .setTitle('Gen error!') 187 | .setDescription(`I do not find the \`${args[0]}\` service in my stock!`) 188 | .setFooter(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 64 })) 189 | .setTimestamp() 190 | ); 191 | 192 | // cancel 193 | return; 194 | }; 195 | }); 196 | }; 197 | 198 | // if not gen channel 199 | } else { 200 | 201 | // send message to channel 202 | message.channel.send( 203 | 204 | // embed 205 | new Discord.MessageEmbed() 206 | .setColor(config.color.red) 207 | .setTitle('Prohibited activity!') 208 | .setDescription(`You can use the ${config.prefix}gen command only in <#${config.genChannel}> channel!`) 209 | .setFooter(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 64 })) 210 | .setTimestamp() 211 | ); 212 | }; 213 | }, 214 | }; -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "token": "", 3 | "prefix": "!", 4 | "genChannel": "", 5 | "genCooldown": "1000", 6 | "color": { 7 | "green": "0x43B581", 8 | "yellow": "0xFAA61A", 9 | "red": "0xF04747", 10 | "default": "0x7289DA" 11 | } 12 | } -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const express = require("express") 2 | const app = express() 3 | 4 | app.get("/", (req, res) => { 5 | res.send("bot is online") 6 | }) 7 | 8 | app.listen(3000, () => { 9 | console.log("project is ready") 10 | }) 11 | // npmjs packages 12 | const Discord = require('discord.js'); 13 | const fs = require('fs'); 14 | 15 | // configuration 16 | const config = require('./config.json'); 17 | 18 | // create client 19 | const client = new Discord.Client(); 20 | 21 | // const commands 22 | client.commands = new Discord.Collection(); 23 | 24 | // load commands 25 | const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); 26 | 27 | // const commands 28 | for (const file of commandFiles) { 29 | 30 | // read command file 31 | const command = require(`./commands/${file}`); 32 | 33 | // set the command 34 | client.commands.set(command.name, command); 35 | }; 36 | 37 | // login with token 38 | client.login(config.token) 39 | 40 | // ready event 41 | client.once('ready', () => { 42 | 43 | // write to console 44 | console.log(`I am logged in as ${client.user.tag} to Discord!`); 45 | 46 | // set activity 47 | client.user.setActivity("Bot made by TusTusDev", { 48 | type: "STREAMING", 49 | url: "https://www.twitch.tv/chillhopmusic" 50 | }) 51 | }); 52 | 53 | // message event // command handling 54 | client.on('message', (message) => { 55 | // command without prefix 56 | if (!message.content.startsWith(config.prefix)) { 57 | // cancel 58 | return; 59 | }; 60 | // if a bot execute a command 61 | if (message.author.bot) { 62 | // cancel 63 | return; 64 | }; 65 | 66 | // get the args 67 | const args = message.content.slice(config.prefix.length).trim().split(/ +/); 68 | 69 | // const command 70 | const command = args.shift().toLowerCase(); 71 | 72 | // if not match 73 | if (!client.commands.has(command)) { 74 | 75 | // send message to channel 76 | //message.channel.send( 77 | 78 | // embed 79 | //new Discord.MessageEmbed() 80 | //.setColor(config.color.red) 81 | //.setTitle('Unknown command') 82 | //.setDescription(`Sorry, but no command match \`${command}\`!`) 83 | //.setFooter(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 64 })) 84 | //.setTimestamp() 85 | // ); 86 | 87 | // cancel 88 | return; 89 | }; 90 | 91 | // try to executing the command 92 | try { 93 | 94 | // get command 95 | client.commands.get(command).execute(message, args); 96 | 97 | // if error 98 | } catch (error) { 99 | 100 | // write to console 101 | console.error(error); 102 | 103 | // send message to channel 104 | message.channel.send( 105 | 106 | // embed 107 | new Discord.MessageEmbed() 108 | .setColor(config.color.red) 109 | .setTitle('Error occurred!') 110 | .setDescription(`An error occurred in \`${command}\` command!`) 111 | .addField('Error', `\`\`\`js\n${error}\n\`\`\``) 112 | .setFooter(message.author.tag, message.author.displayAvatarURL({ dynamic: true, size: 64 })) 113 | .setTimestamp() 114 | ); 115 | }; 116 | }); 117 | -------------------------------------------------------------------------------- /stock/Put somthing here.txt: -------------------------------------------------------------------------------- 1 | somthing --------------------------------------------------------------------------------