Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. const chalk = require('chalk');
  2. const inquirer = require('inquirer');
  3. const figlet = require('figlet');
  4. const fs = require('fs');
  5.  
  6. var configFile = JSON.parse(fs.readFileSync('./config.json', 'utf8'));
  7. var initq = [
  8. {
  9. name: 'usage',
  10. type: 'list',
  11. message: 'What are you using this tool to do?',
  12. choices: ['Setup qbot for the first time.', 'Update the cookie.']
  13. }
  14. ]
  15. var updateq = [
  16. {
  17. name: 'cookie',
  18. type: 'input',
  19. message: 'What is the Roblox bot cookie?',
  20. validate: function(value){
  21. if(value.length){
  22. return true;
  23. } else {
  24. return 'This field is required.';
  25. }
  26. }
  27. }
  28. ]
  29. var setupq = [
  30. {
  31. name: 'token',
  32. type: 'input',
  33. message: 'What is the Discord bot token?',
  34. validate: function(value){
  35. if(value.length){
  36. return true;
  37. } else {
  38. return 'This field is required.';
  39. }
  40. }
  41. },
  42. {
  43. name: 'prefix',
  44. type: 'input',
  45. message: 'What is the Discord bot prefix?',
  46. validate: function(value){
  47. if(value.length){
  48. return true;
  49. } else {
  50. return 'This field is required.';
  51. }
  52. }
  53. },
  54. {
  55. name: 'cookie',
  56. type: 'input',
  57. message: 'What is the Roblox bot cookie?',
  58. validate: function(value){
  59. if(value.length){
  60. return true;
  61. } else {
  62. return 'This field is required.';
  63. }
  64. }
  65. },
  66. {
  67. name: 'groupId',
  68. type: 'number',
  69. message: 'What is the Roblox group ID?'
  70. },
  71. {
  72. name: 'maximumRank',
  73. type: 'number',
  74. message: 'What is the Roblox maximum rank number?'
  75. },
  76. {
  77. name: 'logchannelid',
  78. type: 'input',
  79. message: 'What is the Discord log channel ID?',
  80. validate: function(value){
  81. if(value.length){
  82. return true;
  83. } else {
  84. return 'This field is required.';
  85. }
  86. }
  87. },
  88. {
  89. name: 'shoutchannelid',
  90. type: 'input',
  91. message: 'What is the Discord shout channel ID?',
  92. validate: function(value){
  93. if(value.length){
  94. return true;
  95. } else {
  96. return 'This field is required.';
  97. }
  98. }
  99. }
  100. ]
  101.  
  102. inquirer.prompt(initq).then(answers => {
  103. if(answers.usage === 'Setup qbot for the first time.'){
  104. inquirer.prompt(setupq).then(answers => {
  105. configFile.token = answers.token;
  106. configFile.prefix = answers.prefix;
  107. configFile.cookie = answers.cookie;
  108. configFile.groupId = answers.groupId;
  109. configFile.maximumRank = answers.maximumRank;
  110. configFile.logchannelid = answers.logchannelid;
  111. configFile.shoutchannelid = answers.shoutchannelid;
  112. fs.writeFile('./config.json', JSON.stringify(configFile), (err) => {
  113. if (err) console.log(err);
  114. });
  115. console.log(chalk.green('bot has been successfully setup.'));
  116. });
  117. } else {
  118. inquirer.prompt(updateq).then(answers => {
  119. configFile.cookie = answers.cookie;
  120. fs.writeFile('./config.json', JSON.stringify(configFile), (err) => {
  121. if (err) console.log(err);
  122. });
  123. console.log(chalk.green('Your bot configuration has been successfully updated.'));
  124. });
  125. }
  126. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement