Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.65 KB | None | 0 0
  1. const Discord = require('discord.js')
  2. const bot = new Discord.Client();
  3. const prefix = '.'
  4. const fs = require('fs');
  5.  
  6. //We can call the JSON file here
  7. const commands = JSON.parse(fs.readFileSync('Storage/commands.json', 'utf8'));
  8. bot.on('message', message => {
  9.  
  10. let msg = message.content.toUpperCase();
  11. let sender = message.author;
  12. let cont = message.content.slice(prefix.length).split(" ");
  13. let args = cont.slice(1);
  14.  
  15. // Commands
  16.  
  17. //Ping
  18. if (msg === prefix + 'PING') {
  19.  
  20. //Purge
  21. if (msg.startsWith(prefix + 'PURGE')) {
  22.  
  23. // Weather Command
  24. // .
  25.  
  26. if (msg.startsWith(prefix + 'WEATHER')) {
  27.  
  28. // This episode will be going over the hook command
  29. if (msg.startsWith(prefix + 'HOOK')) {
  30.  
  31. // Help
  32. if (msg.startsWith(prefix + 'HELP')) {
  33.  
  34. if (msg === `${prefix}HELP`) {
  35.  
  36.  
  37. const embed = new Discord.RichEmbed()
  38. .setColor(0x1D82B6)
  39.  
  40. //Variables
  41. let commandsFound = 0;
  42.  
  43. // .
  44. for (var cmd in commands) {
  45.  
  46.  
  47.  
  48. if (commands[cmd].group.toUpperCase() === 'USER') {
  49. //.
  50. commandsFound++
  51. //.
  52. embed.addField(`${commands[cmd].name}`, `**Description:** ${commands[cmd].desc}\n**Usage:** ${prefix + commands[cmd].usage}`);
  53. }
  54.  
  55. //.
  56.  
  57.  
  58. }
  59.  
  60. //.
  61. embed.setFooter(`Currently showing user commands. To view another group do ${prefix}help [group / command]`)
  62. embed.setDescription(`**${commandsFound} commands found** - <> means required, [] means optional`);
  63. //.
  64. message.author.send({embed})
  65. //.
  66. message.channel.send({embed: {
  67. color: 0x1D82B6,
  68. description: `**Check your DMs ${message.author}!**`
  69. }})
  70.  
  71. //.
  72. //.
  73.  
  74. //.
  75.  
  76. } else {
  77. // .
  78.  
  79. //Variables
  80. let groupFound = '';
  81.  
  82. for (var cmd in commands) {
  83.  
  84. if (args.join(" ").trim().toUpperCase() === commands[cmd].group.toUpperCase()) {
  85. groupFound = commands[cmd].group.toUpperCase();
  86. }
  87.  
  88. }
  89.  
  90. if (groupFound != '') {
  91.  
  92. const embed = new Discord.RichEmbed()
  93. .setColor(0x1D82B6)
  94.  
  95. //Variables
  96. let commandsFound = 0;
  97.  
  98. for (var cmd in commands) {
  99.  
  100.  
  101.  
  102. if (commands[cmd].group.toUpperCase() === groupFound) {
  103. //.
  104. commandsFound++
  105. //.
  106. embed.addField(`${commands[cmd].name}`, `**Description:** ${commands[cmd].desc}\n**Usage:** ${prefix + commands[cmd].usage}`);
  107. }
  108. }
  109.  
  110. //.
  111. embed.setFooter(`Currently showing ${groupFound} commands. To view another group do ${prefix}help [group / command]`)
  112. embed.setDescription(`**${commandsFound} commands found** - <> means required, [] means optional`);
  113. //.
  114. message.author.send({embed})
  115. //.
  116. message.channel.send({embed: {
  117. color: 0x1D82B6,
  118. description: `**Check your DMs ${message.author}!**`
  119. }})
  120.  
  121. //.
  122.  
  123. }
  124.  
  125.  
  126. }
  127. }
  128.  
  129. }
  130.  
  131. }
  132.  
  133. }
  134.  
  135. }
  136. });
  137.  
  138. bot.on('ready', () => {
  139. //.
  140. console.log(`${bot.user.username} is ingelogd bij StormCompany`)
  141. });
  142.  
  143. bot.login('NjYyNTcwMzg4MTQ3OTI5MDg4.Xg9dSQ.FzV2eeEov5aS4cfuGp9snWDZM4Q')
  144.  
  145.  
  146.  
  147.  
  148.  
  149. Commands
  150. {
  151. "Help": {
  152. "name": "Help",
  153. "group": "User",
  154. "desc": "Displays a list of commands",
  155. "usage": "help [group OR command]"
  156. },
  157. "Hook": {
  158. "name": "Hook",
  159. "group": "User",
  160. "desc": "Returns a hook in the channel",
  161. "usage": "hook <title>,<description>,[color],[avatarURL]"
  162. },
  163. "Weather": {
  164. "name": "Weather",
  165. "group": "User",
  166. "desc": "Returns the weather in the channel",
  167. "usage": "weather <location>"
  168. },
  169. "Purge": {
  170. "name": "Purge",
  171. "group": "Moderator",
  172. "desc": "Clears a specified number of messages",
  173. "usage": "purge <messages>"
  174. },
  175. "Ping": {
  176. "name": "Ping",
  177. "group": "Admin",
  178. "desc": "Returns the ping to the channel",
  179. "usage": "ping"
  180. }
  181. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement