Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. const Discord = require('discord.js');
  2.  
  3. exports.run = (bot, message, args, func) => {
  4.  
  5. const embed = new Discord.RichEmbed()
  6. .setColor(0x1D82B6)
  7.  
  8. let commandsFound = 0;
  9. const commands = JSON.parse(fs.readFileSync('Storage/commands.json', 'utf8'));
  10.  
  11. for (var cmd in commands) {
  12.  
  13. if (commands[cmd].group.toUpperCase() === 'USER') {
  14. commandsFound++
  15. embed.addField(`${commands[cmd].name}`, `**Description:** ${commands[cmd].desc}\n**Usage:** ${prefix + commands[cmd].usage}`); // This will output something like <commandname>[title] [newline] desc: <description> [newline] usage: <usage
  16. }
  17.  
  18. }
  19.  
  20. embed.setFooter(`Currently showing user commands. To view another group do ${prefix}help [group / command]`)
  21. embed.setDescription(`**${commandsFound} commands found** - <> means required, [] means optional`)
  22.  
  23. message.author.send({embed})
  24. message.channel.send({embed: {
  25. color: 0x1D82B6,
  26. description: `**Check your DMs ${message.author}!**`
  27. }})
  28.  
  29.  
  30. if (args.join(" ").toUpperCase() === 'GROUPS') {
  31.  
  32. let groups = '';
  33.  
  34. for (var cmd in commands) {
  35. if (!groups.includes(commands[cmd].group)) {
  36. groups += `${commands[cmd].group}\n`
  37. }
  38. }
  39.  
  40. message.channel.send({embed: {
  41. description:`**${groups}**`,
  42. title:"Groups",
  43. color: 0x1D82B6
  44. }})
  45.  
  46. return;
  47.  
  48.  
  49. } else {
  50.  
  51. let groupFound = '';
  52.  
  53. for (var cmd in commands) {
  54.  
  55. if (args.join(" ").trim().toUpperCase() === commands[cmd].group.toUpperCase()) {
  56. groupFound = commands[cmd].group.toUpperCase();
  57. break;
  58. }
  59.  
  60. }
  61.  
  62. if (groupFound != '') {
  63.  
  64. // Start of the embed
  65. const embed = new Discord.RichEmbed()
  66. .setColor(0x1D82B6)
  67.  
  68. // Variables
  69. let commandsFound = 0;
  70.  
  71.  
  72. for (var cmd in commands) {
  73.  
  74. if (commands[cmd].group.toUpperCase() === groupFound) {
  75. commandsFound++
  76. embed.addField(`${commands[cmd].name}`, `**Description:** ${commands[cmd].desc}\n**Usage:** ${prefix + commands[cmd].usage}`); // This will output something like <commandname>[title] [newline] desc: <description> [newline] usage: <usage
  77. }
  78.  
  79. }
  80.  
  81. embed.setFooter(`Currently showing ${groupFound} commands. To view another group do ${prefix}help [group / command]`)
  82. embed.setDescription(`**${commandsFound} commands found** - <> means required, [] means optional`)
  83.  
  84. message.author.send({embed})
  85. message.channel.send({embed: {
  86. color: 0x1D82B6,
  87. description: `**Check your DMs ${message.author}!**`
  88. }})
  89.  
  90. return;
  91.  
  92. }
  93.  
  94.  
  95. let commandFound = '';
  96. let commandDesc = '';
  97. let commandUsage = '';
  98. let commandGroup = '';
  99.  
  100. for (var cmd in commands) {
  101.  
  102. if (args.join(" ").trim().toUpperCase() === commands[cmd].name.toUpperCase()) {
  103. commandFound = commands[cmd].name;
  104. commandDesc = commands[cmd].desc;
  105. commandUsage = commands[cmd].usage;
  106. commandGroup = commands[cmd].group;
  107. break;
  108. }
  109.  
  110. }
  111.  
  112. if (commandFound === '') {
  113. message.channel.send({embed: {
  114. description:`**No group or command found titled \`${args.join(" ")}\`**`,
  115. color: 0x1D82B6,
  116. }})
  117.  
  118. }
  119.  
  120. message.channel.send({embed: {
  121. title:'<> means required, [] means optional',
  122. color: 0x1D82B6,
  123. fields: [{
  124. name:commandFound,
  125. value:`**Description:** ${commandDesc}\n**Usage:** ${commandUsage}\n**Group:** ${commandGroup}`
  126. }]
  127. }})
  128.  
  129. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement