Advertisement
Guest User

Generator Bot Source Code

a guest
Nov 17th, 2018
467
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const express = require('express');
  2. const app = express();
  3. const prefix = "gen-";
  4. const randomWords = require('random-words');
  5. const request = require("request");
  6. const Discord = require("discord.js");
  7. const client = new Discord.Client();
  8.  
  9. client.on('ready' , () => {
  10. client.user.setActivity("for gen-help | " + client.users.size + " users", { type: "watching"})
  11. });
  12.  
  13. client.on('message', async message => {
  14. function cmd(commandName) {
  15. if(message.content.toLowerCase() === prefix + commandName.toLowerCase()) {
  16. return true;
  17. } else {
  18. return false;
  19. }
  20. };
  21. function cmdSW(commandName) {
  22. if(message.content.toLowerCase().startsWith(prefix + commandName.toLowerCase())) {
  23. return true;
  24. } else {
  25. return false;
  26. }
  27. };
  28. function send(messageToSend) {
  29. message.channel.send(messageToSend);
  30. };
  31. if(cmd("help")) {
  32. let embed = new Discord.RichEmbed()
  33. .setTitle("Help me dude!")
  34. .addField("Commands", "**" + prefix + "clan**: Generates a random clan name.\n**" + prefix + "urban**: Generates a random word and collects the urban dictionary definition for it.\n**" + prefix + "reddit**: Finds the latest post on a random subreddit.\n**" + prefix + "r/<subreddit>**: Finds the latest post on the chosen subreddit.\n**" + prefix + "u/<username>**: Finds the latest post from the chosen user.\n**" + prefix + "clan-suggest <suggestion>**: Sends a suggestion to the dev to add the words to the clan name generator database.\n**" + prefix + "dab**: DAB BOIIIIIIIIIII!\n**" + prefix + "oof**: OOF!")
  35. .setFooter("Bot made by some gay dude by the name of " + client.users.get("336366633750888448").tag)
  36. message.channel.send("Please wait, collecting help command...").then((msg)=>{
  37. setTimeout(function(){ msg.edit(embed) }, 1000);
  38. })
  39. }
  40. if(cmd("clan")) {
  41. let firstWord = ["", "Hazard", "Danger", "Reck", "Ultimate", "Damage", "Super", "Hard", "Multiple", "Edon", "Krak", "Zag"];
  42. let secondWord = ["", "Area", "Aim", "Rockers", "Snipez", "Λttackz", "Battering", "Hitz", "420", "Noscoperz", "Upz", "Λlarmz"];
  43. send("Your generated clan tag is: ``" + firstWord[Math.random() * 10 + 1 | 0] + secondWord[Math.random() * 10 + 1 | 0] + "``");
  44. };
  45. if(cmd("oof")) {
  46. setTimeout(function(){ message.react("🇴") }, 1000);
  47. setTimeout(function(){ message.react("🅾") }, 2000);
  48. setTimeout(function(){ message.react("🇫") }, 3000);
  49. }
  50. if(cmdSW("clan-suggest")) {
  51. let args = message.content.split(" ")
  52. let embed = new Discord.RichEmbed()
  53. if(args.length === 3) {
  54. embed.setTitle("New Suggestion! \:pencil2:\:newspaper:")
  55. embed.addField("New Suggestion from " + message.author.tag, message.content.slice(prefix.length + "clan-suggest ".length))
  56. client.channels.get("505490013811900437").send(embed)
  57. .then(function (message) {
  58. setTimeout(function(){ message.react("👍") }, 500);
  59. setTimeout(function(){ message.react("👎") }, 600);
  60. });
  61. send("Suggestion sent!")
  62. } else if (args.length < 3) {
  63. send("Incorrect Syntax! Please suggest 2 words seperated with spaces. Ex: Oofer Gang")
  64. } else if (args.length > 3) {
  65. send("Incorrent Syntax! Please suggest 2 words seperated with spaces. Ex: Oofer Gang")
  66. } else {
  67. send("Incorrent Syntax! Please suggest 2 words seperated with spaces. Ex: Oofer Gang")
  68. }
  69. };
  70. if(cmd("urban")) {
  71. let embed = new Discord.RichEmbed();
  72. var term = randomWords();
  73. request('http://api.urbandictionary.com/v0/define?term=' + term, function (error, response, body) {
  74. body = JSON.parse(body);
  75. if(body) {
  76. let defintionFixed1 = body["list"][0]["definition"].toString().split("]");
  77. let defintionFixed2 = defintionFixed1.toString().split("[");
  78. let defintionFixed3 = defintionFixed2.toString().split(",");
  79. let definition = defintionFixed3.join("");
  80. let thumbsUp = body["list"][0]["thumbs_up"];
  81. let thumbsDown = body["list"][0]["thumbs_down"];
  82. embed.setTitle(term.charAt(0).toUpperCase() + term.slice(1));
  83. embed.addField("Definition", definition + "\n\n[Urban Dictionary Page](https://www.urbandictionary.com/define.php?term=" + term + ")");
  84. embed.setFooter("\👍 " + thumbsUp + " | \👎 " + thumbsDown);
  85. send(embed);
  86. } else {
  87. send("Word Not Found!");
  88. }
  89. })
  90. };
  91. if(cmd("uptime")) {
  92. message.channel.send(process.uptime() + " seconds!")
  93. }
  94. if(cmd("dab")) {
  95. let dab_Database = ["", "<o/", "\\o>", "<o>", "\\o/", "ヽ( •_)ᕗ", "\( ͡° ͜ʖ ͡°) >"]
  96. let editLength = Math.random() * (Math.random() * 5 + 1 | 0) * 5 + 1 | 0
  97. let i = 0
  98. let dabs = "<o/ "
  99. while(i < editLength) {
  100. dabs = dabs + dab_Database[Math.random() * 6 + 1 | 0] + " "
  101. i = i + 1
  102. }
  103. let embed = new Discord.RichEmbed()
  104. .setTitle("OOF you dab? Well I dab too!")
  105. .addField("Here are your great generated dabs!", dabs)
  106. send(embed)
  107. }
  108. if(cmd("reddit")) {
  109. request('https://reddit.com/r/random/comments.json?limit=1', function (error, response, body) {
  110. body = JSON.parse(body);
  111. let embed = new Discord.RichEmbed();
  112. embed.setTitle("Reddit: " + body["data"]["children"][0]["data"]["subreddit_name_prefixed"])
  113. embed.addField("Body: ", body["data"]["children"][0]["data"]["body"])
  114. if(body["data"]["children"][0]["data"]["link_url"].toString().startsWith("https://i.redd.it/")) {
  115. embed.setImage(body["data"]["children"][0]["data"]["link_url"])
  116. }
  117. send(embed)
  118. });
  119. };
  120. if(cmdSW("r/")) {
  121. request('https://reddit.com/r/' + message.content.slice(prefix.length + "r/".length) + '/comments.json?limit=1', function (error, response, body) {
  122. body = JSON.parse(body);
  123. let embed = new Discord.RichEmbed();
  124. embed.setTitle("Reddit: " + body["data"]["children"][0]["data"]["subreddit_name_prefixed"])
  125. embed.addField("Body: ", body["data"]["children"][0]["data"]["body"])
  126. if(body["data"]["children"][0]["data"]["link_url"].toString().startsWith("https://i.redd.it/")) {
  127. embed.setImage(body["data"]["children"][0]["data"]["link_url"])
  128. }
  129. send(embed)
  130. })
  131. }
  132. if(cmdSW("u/")) {
  133. request('https://reddit.com/u/' + message.content.slice(prefix.length + "r/".length) + '/comments.json?limit=1', function (error, response, body) {
  134. body = JSON.parse(body);
  135. let embed = new Discord.RichEmbed();
  136. let status
  137. if(JSON.stringify(body) === '{"message":"Not Found","error":404}') {
  138. status = false;
  139. } else {
  140. status = true;
  141. }
  142. if(status) {
  143. embed.setTitle("Username: " + body["data"]["children"][0]["data"]["author"])
  144. embed.addField(body["data"]["children"][0]["data"]["author"] + "'s latest post in " + body["data"]["children"][0]["data"]["subreddit_name_prefixed"], body["data"]["children"][0]["data"]["body"])
  145. if(body["data"]["children"][0]["data"]["link_url"].toString().startsWith("https://i.redd.it/")) {
  146. embed.setImage(body["data"]["children"][0]["data"]["link_url"])
  147. }
  148. } else {
  149. embed.addField("Uh oh!", "Well this is embarrassing, that user does not seem to exist!")
  150. }
  151. send(embed)
  152. })
  153. }
  154. });
  155.  
  156. app.use(express.static('public'));
  157. app.get('/', function(request, response) {
  158. response.sendFile(__dirname + "/views/home/index.html");
  159. });
  160. app.get('/gen-stable', function(request, response) {
  161. response.sendFile(__dirname + "/views/generator/stable/index.html");
  162. });
  163. app.get('/gen-beta', function(request, response) {
  164. response.sendFile(__dirname + "/views/generator/beta/index.html");
  165. });
  166. app.get('/setup', function(request, response) {
  167. response.sendFile(__dirname + "/views/setup/stable/index.html");
  168. });
  169. app.get('/image', function(request, response) {
  170. response.sendFile(__dirname + "/views/image/stable/index.html");
  171. });
  172. app.get('/inc', function(request, response) {
  173. response.sendFile(__dirname + "/views/inc/stable/index.html");
  174. });
  175. app.get('/dinosaur', function(request, response) {
  176. response.sendFile(__dirname + "/views/dinosaur/stable/index.html");
  177. });
  178. app.get('/sha-256', function(request, response) {
  179. response.sendFile(__dirname + "/views/misc/sha256/index.html");
  180. });
  181. app.get('/sprokket', function(request, response) {
  182. response.sendFile(__dirname + "/views/misc/sprokket/index.html");
  183. });
  184. const listener = app.listen(process.env.PORT, function() {
  185. console.log("yay the bot is actually online");
  186. });
  187.  
  188. client.login(process.env.TOKEN);
Advertisement
RAW Paste Data Copied
Advertisement