Advertisement
Andy0009

Untitled

Nov 25th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.10 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const botconfig = require("./botconfig.json");
  3. const { stripIndents } = require("common-tags");
  4. const bot = new Discord.Client();
  5. const stockxAPI = require('stockx-api');
  6. const stockx = new stockxAPI();
  7. const request = require("request");
  8.  
  9. bot.on("message", message => {
  10.  
  11. if(message.channel.type == `dm`) return
  12. if(message.author.bot) return
  13.  
  14. if(message.content.startsWith(botconfig.prefix + 'release')){
  15.  
  16. message.channel.send("✅ What is the name of the shoe?");
  17. let collector1 = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, {});
  18. collector1.on('collect', message1 => {
  19. let channelName = message1.content
  20. collector1.stop()
  21. if(channelName.toLowerCase() == `stop`) return message.channel.send(`The process has been canceled.`)
  22.  
  23. message.channel.send("✅ When is the release date of the shoe?");
  24. let collector2 = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, {});
  25. collector2.on('collect', message2 => {
  26. let releaseDate = message2.content
  27. collector2.stop()
  28. if(releaseDate.toLowerCase() == `stop`) return message.channel.send(`The process has been canceled.`)
  29.  
  30. message.channel.send("✅ Are you using a StockX link (1) or a from-scratch process (2)? Please only say one of those two numbers.");
  31. let collector3 = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, {});
  32. collector3.on('collect', message3 => {
  33. let yesorno = message3.content
  34. collector3.stop()
  35. if(yesorno.toLowerCase() == `stop`) return message.channel.send(`The process has been canceled.`)
  36. if(yesorno == `1`){
  37.  
  38. message.channel.send("✅ What is the StockX link for the shoe?");
  39. let collector4 = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, {});
  40. collector4.on('collect', message3 => {
  41. let link = message3.content
  42. collector4.stop()
  43. if(link.toLowerCase() == `stop`) return message.channel.send(`The process has been canceled.`)
  44.  
  45. message.channel.send("✅ Fetching StockX details.");
  46.  
  47. (async () => {
  48.  
  49. let product = await stockx.fetchProductDetails(link)
  50. let uuid = product.uuid
  51. let requestLink = `https://stockx.com/api/products/${uuid}`
  52.  
  53. var options = {
  54. method: 'GET',
  55. url: requestLink,
  56. qs: {
  57. currency: 'USD',
  58. country: 'US'
  59. },
  60. headers: {
  61. 'User-Agent': 'request'
  62. }
  63. };
  64.  
  65. request(options, function (error, response, body) {
  66.  
  67. if (error) throw new Error(error);
  68.  
  69. try {
  70. JSON.parse(body)
  71. } catch(e) {
  72. return message.channel.send(`Error. Please try again, maybe using a different link.`)
  73. }
  74.  
  75. let output = JSON.parse(body)
  76. let result = output.Product
  77. let colorway = result.colorway
  78. let SKU = result.styleId
  79. let name = result.shoe
  80. let image = result.media.imageUrl
  81. message.channel.send("✅ Creating embed.");
  82.  
  83. let embed = new Discord.RichEmbed()
  84. .setColor(5191048)
  85. .setTitle(`${name} Upcoming Release`)
  86. .setURL(link)
  87. .addField(`**Release Date:**`, `>>> ${releaseDate}`, true)
  88. .addField(`**Style Code:**`, `>>> ${SKU}`, true)
  89. .addField(`**Colorway:**`, `>>> ${colorway}`, false)
  90. .setFooter(`The Bandit Block | More info regarding this drop will be posted!`, `https://cdn.discordapp.com/attachments/582271749165678613/582275753207398400/Footer-Icon.png`)
  91. .setImage(image)
  92.  
  93. let modRole = message.guild.roles.find(r => r.id === `610614520783699989`)
  94. let managerRole = message.guild.roles.find(r => r.id === `643584371634470922`)
  95. let devRole = message.guild.roles.find(r => r.id === `610673759590023168`)
  96.  
  97. let regex = /\//gi;
  98. let datee = releaseDate.replace(regex, ` `);
  99. let dateee = datee.split(" ");
  100.  
  101. //makes channel
  102. (async () => {
  103.  
  104. let channel = await message.guild.createChannel(`${dateee[0]}-${dateee[1]}│${channelName}`, {
  105. type: 'text',
  106. permissionOverwrites: [{
  107. id: message.guild.defaultRole.id,
  108. deny: ['VIEW_CHANNEL']
  109. },
  110. {
  111. id: managerRole.id,
  112. allow: ['VIEW_CHANNEL']
  113.  
  114. },
  115. {
  116. id: devRole.id,
  117. allow: ['VIEW_CHANNEL']
  118.  
  119. }]
  120. })
  121.  
  122. channel = await channel.setParent(`638166553514344478`);
  123.  
  124. await channel.send(embed)
  125.  
  126. await message.channel.send(`✅ Made and sent to channel ${channel}`);
  127.  
  128. })();
  129. });
  130. })()
  131.  
  132. })
  133. } else if(yesorno == `2`){
  134.  
  135. message.channel.send("✅ What is the SKU of the shoe?");
  136. let collector21 = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, {});
  137. collector21.on('collect', message21 => {
  138. let SKU = message21.content
  139. collector21.stop()
  140. if(SKU.toLowerCase() == `stop`) return message.channel.send(`The process has been canceled.`)
  141.  
  142. message.channel.send("✅ What is the colorway of the shoe?");
  143. let collector22 = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, {});
  144. collector22.on('collect', message22 => {
  145. let colorway = message22.content
  146. collector22.stop()
  147. if(colorway.toLowerCase() == `stop`) return message.channel.send(`The process has been canceled.`)
  148.  
  149. message.channel.send("✅ What is the image you would like to use?");
  150. let collector23 = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, {});
  151. collector23.on('collect', message23 => {
  152. let result;
  153. if(message23.attachments.length == 0){
  154. result = message23.content
  155. } else {
  156. let resultt = message23.attachments.map((res, i) => {
  157. return res.proxyURL;
  158. });
  159. result = resultt[0]
  160. }
  161. collector23.stop()
  162.  
  163. let embed = new Discord.RichEmbed()
  164. .setColor(5191048)
  165. .setTitle(`${channelName} Upcoming Release`)
  166. .addField(`**Release Date:**`, `>>> ${releaseDate}`, true)
  167. .addField(`**Style Code:**`, `>>> ${SKU}`, true)
  168. .addField(`**Colorway:**`, `>>> ${colorway}`, false)
  169. .setFooter(`The Bandit Block | More info regarding this drop will be posted!`, `https://cdn.discordapp.com/attachments/582271749165678613/582275753207398400/Footer-Icon.png`)
  170. .setImage(result)
  171.  
  172. let modRole = message.guild.roles.find(r => r.id === `610614520783699989`)
  173. let managerRole = message.guild.roles.find(r => r.id === `643584371634470922`)
  174. let devRole = message.guild.roles.find(r => r.id === `610673759590023168`)
  175.  
  176. let regex = /\//gi;
  177. let datee = releaseDate.replace(regex, ` `);
  178. let dateee = datee.split(" ");
  179.  
  180. //makes channel
  181. (async () => {
  182.  
  183. let channel = await message.guild.createChannel(`${dateee[0]}-${dateee[1]}│${channelName}`, {
  184. type: 'text',
  185. permissionOverwrites: [{
  186. id: message.guild.defaultRole.id,
  187. deny: ['VIEW_CHANNEL']
  188. },
  189. {
  190. id: managerRole.id,
  191. allow: ['VIEW_CHANNEL']
  192.  
  193. },
  194. {
  195. id: devRole.id,
  196. allow: ['VIEW_CHANNEL']
  197.  
  198. }]
  199. })
  200.  
  201. channel = await channel.setParent(`638166553514344478`);
  202.  
  203. await channel.send(embed)
  204.  
  205. await message.channel.send(`✅ Made and sent to channel ${channel}`);
  206.  
  207. })();
  208.  
  209. })
  210. })
  211. })
  212.  
  213. } else {
  214. return message.channel.send(`❌You did not anss`)
  215. }
  216. })
  217. })
  218. })
  219. }
  220. })
  221.  
  222. bot.on("ready", ready => {
  223. console.log(`Online`)
  224. })
  225.  
  226. bot.login(botconfig.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement