gaber-elsayed

auto chanage tag discord #2

May 17th, 2020
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. config.json/*
  2. {
  3. "botToken": "",
  4. "userAccountPassword": "",
  5. "desiredDiscrim": "0001",
  6. "changeInterval": "3600000"
  7. }
  8. */
  9. const Discord = require('discord.js');
  10. const client = exports.client = new Discord.Client();
  11.  
  12. const config = require('../config.json');
  13.  
  14. client.once('ready', () => {
  15. console.log(`Discriminator changer is running!`);
  16.  
  17. client.user.setGame(`Changing my discriminator to ${config.desiredDiscrim}`);
  18.  
  19. changeDiscriminator();
  20. });
  21.  
  22. function changeDiscriminator() {
  23.  
  24. let x = 0;
  25.  
  26. let discrimInterval = setInterval(function () {
  27.  
  28. client.user.setUsername(fetchUsername(), config.userAccountPassword).catch(err => {
  29. console.error(`Unable to change nickname, Error: ${err.stack}`)
  30. });
  31.  
  32. if (x % 10 === 0) {
  33. console.log(`Done trying ${x} usernames! Still going!`);
  34. }
  35.  
  36. if (checkDiscrim()) {
  37. clearInterval(discrimInterval);
  38. console.log(`You have reached your desired discriminator!`)
  39. }
  40.  
  41. x++;
  42.  
  43. }, config.changeInterval);
  44.  
  45. }
  46.  
  47. function fetchUsername() {
  48. client.users.array().forEach(users => {
  49. if (users.username !== client.user.username && users.discriminator === client.user.discriminator){
  50. return users.username;
  51. }
  52. })
  53. }
  54.  
  55. function checkDiscrim() {
  56. return client.user.discriminator == config.desiredDiscrim;
  57. }
  58.  
  59. client.login(config.botToken).catch(err => {console.error(err.stack)});
Add Comment
Please, Sign In to add comment