Advertisement
Guest User

giveaway commanf

a guest
Oct 21st, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.98 KB | None | 0 0
  1.  
  2. {
  3. "name": "gcreate",
  4. "permissions": "NONE",
  5. "restriction": "1",
  6. "_id": "DvDki",
  7. "actions": [
  8. {
  9. "member": "1",
  10. "varName": "",
  11. "permission": "MANAGE_MESSAGES",
  12. "iftrue": "0",
  13. "iftrueVal": "",
  14. "iffalse": "2",
  15. "iffalseVal": "45",
  16. "name": "Check Member Permissions"
  17. },
  18. {
  19. "storage": "1",
  20. "varName": "maxLoopCAP",
  21. "changeType": "0",
  22. "value": "0",
  23. "name": "Control Variable"
  24. },
  25. {
  26. "channel": "0",
  27. "varName": "",
  28. "message": "What are you giving away?",
  29. "storage": "1",
  30. "varName2": "giveawayPrompt",
  31. "name": "Send Message"
  32. },
  33. {
  34. "storage": "1",
  35. "varName": "maxLoopCAP",
  36. "changeType": "1",
  37. "value": "1",
  38. "name": "Control Variable"
  39. },
  40. {
  41. "behavior": "1",
  42. "interpretation": "1",
  43. "code": "\n const _this = this;\n\n msg.channel.awaitMessages(response => response, {\n max: 1,\n time: 30000,\n errors: ['time'],\n })\n .then((collected) => {\n _this.storeValue(collected.first(), 1, \"giveawayObject\", cache);\n _this.callNextAction(cache);\n })\n .catch((error) => {\n console.log(error);\n msg.channel.send('Command timeout!');\n });\n",
  44. "storage": "0",
  45. "varName": "",
  46. "name": "Run Script"
  47. },
  48. {
  49. "message": "0",
  50. "varName": "",
  51. "info": "3",
  52. "storage": "1",
  53. "varName2": "msgAuthor",
  54. "name": "Store Message Info"
  55. },
  56. {
  57. "message": "1",
  58. "varName": "giveawayObject",
  59. "info": "3",
  60. "storage": "1",
  61. "varName2": "responseAuthor",
  62. "name": "Store Message Info"
  63. },
  64. {
  65. "storage": "1",
  66. "varName": "maxLoopCAP",
  67. "comparison": "1",
  68. "value": "20",
  69. "iftrue": "2",
  70. "iftrueVal": "41",
  71. "iffalse": "0",
  72. "iffalseVal": "3",
  73. "name": "Check Variable"
  74. },
  75. {
  76. "storage": "1",
  77. "varName": "msgAuthor",
  78. "comparison": "1",
  79. "value": "tempVars(\"responseAuthor\")",
  80. "iftrue": "0",
  81. "iftrueVal": "",
  82. "iffalse": "2",
  83. "iffalseVal": "4",
  84. "name": "Check Variable"
  85. },
  86. {
  87. "storage": "1",
  88. "varName": "maxLoopCAP",
  89. "changeType": "0",
  90. "value": "0",
  91. "name": "Control Variable"
  92. },
  93. {
  94. "behavior": "0",
  95. "interpretation": "0",
  96. "code": "msg.author.lastMessage.delete();",
  97. "storage": "0",
  98. "varName": "",
  99. "name": "Run Script"
  100. },
  101. {
  102. "storage": "1",
  103. "varName": "giveawayPrompt",
  104. "message": "How many winners would you like to have?",
  105. "name": "Edit Message"
  106. },
  107. {
  108. "storage": "1",
  109. "varName": "maxLoopCAP",
  110. "changeType": "1",
  111. "value": "1",
  112. "name": "Control Variable"
  113. },
  114. {
  115. "behavior": "1",
  116. "interpretation": "0",
  117. "code": "\n const _this = this;\n\n msg.channel.awaitMessages(response => response, {\n max: 1,\n time: 30000,\n errors: ['time'],\n })\n .then((collected) => {\n _this.storeValue(collected.first(), 1, \"numberOfMembers\", cache);\n _this.callNextAction(cache);\n })\n .catch((error) => {\n console.log(error);\n msg.channel.send('Command timeout!');\n });\n",
  118. "storage": "0",
  119. "varName": "",
  120. "name": "Run Script"
  121. },
  122. {
  123. "message": "1",
  124. "varName": "numberOfMembers",
  125. "info": "3",
  126. "storage": "1",
  127. "varName2": "responseAuthor",
  128. "name": "Store Message Info"
  129. },
  130. {
  131. "storage": "1",
  132. "varName": "maxLoopCAP",
  133. "comparison": "4",
  134. "value": "20",
  135. "iftrue": "2",
  136. "iftrueVal": "41",
  137. "iffalse": "0",
  138. "iffalseVal": "3",
  139. "name": "Check Variable"
  140. },
  141. {
  142. "storage": "1",
  143. "varName": "msgAuthor",
  144. "comparison": "1",
  145. "value": "tempVars(\"responseAuthor\")",
  146. "iftrue": "0",
  147. "iftrueVal": "",
  148. "iffalse": "2",
  149. "iffalseVal": "13",
  150. "name": "Check Variable"
  151. },
  152. {
  153. "storage": "1",
  154. "varName": "maxLoopCAP",
  155. "changeType": "0",
  156. "value": "0",
  157. "name": "Control Variable"
  158. },
  159. {
  160. "behavior": "1",
  161. "interpretation": "0",
  162. "code": "msg.author.lastMessage.delete()\nvar numberOfMembers = tempVars('numberOfMembers').content\nvar giveawayPrompt = tempVars('giveawayPrompt')\n\nif (!isNaN(numberOfMembers) && parseInt(numberOfMembers) > 0) {\n var numberOfWinners = parseInt(numberOfMembers)\n this.storeValue(numberOfMembers, 1, 'numberOfMembers', cache)\n this.callNextAction(cache)\n} else {\n msg.channel.send({\n embed: {\n color: 0xff6666,\n author: {\n name: 'Error - Invalid Number',\n icon_url: (client || this.getDBM().Bot.bot).user.avatarURL\n },\n description: 'You have entered a invalid number of members, please activate the command again to retry \\n \\n Some example responses are 1, 5, or 7'\n }\n })\n giveawayPrompt.delete()\n}",
  163. "storage": "0",
  164. "varName": "",
  165. "name": "Run Script"
  166. },
  167. {
  168. "storage": "1",
  169. "varName": "giveawayPrompt",
  170. "message": "How long do you want the giveaway to last in days/hours/minutes?\n\nEx. I want the giveaway to last 1 day so I would respond with\n1d ",
  171. "name": "Edit Message"
  172. },
  173. {
  174. "storage": "1",
  175. "varName": "maxLoopCAP",
  176. "changeType": "1",
  177. "value": "1",
  178. "name": "Control Variable"
  179. },
  180. {
  181. "behavior": "1",
  182. "interpretation": "0",
  183. "code": "\n const _this = this;\n\n msg.channel.awaitMessages(response => response, {\n max: 1,\n time: 30000,\n errors: ['time'],\n })\n .then((collected) => {\n _this.storeValue(collected.first(), 1, \"giveawayTime\", cache);\n _this.callNextAction(cache);\n })\n .catch((error) => {\n console.log(error);\n msg.channel.send('Command timeout!');\n });\n",
  184. "storage": "0",
  185. "varName": "",
  186. "name": "Run Script"
  187. },
  188. {
  189. "message": "1",
  190. "varName": "giveawayTime",
  191. "info": "3",
  192. "storage": "1",
  193. "varName2": "responseAuthor",
  194. "name": "Store Message Info"
  195. },
  196. {
  197. "storage": "1",
  198. "varName": "maxLoopCAP",
  199. "comparison": "4",
  200. "value": "20",
  201. "iftrue": "2",
  202. "iftrueVal": "41",
  203. "iffalse": "0",
  204. "iffalseVal": "3",
  205. "name": "Check Variable"
  206. },
  207. {
  208. "storage": "1",
  209. "varName": "msgAuthor",
  210. "comparison": "1",
  211. "value": "tempVars(\"responseAuthor\")",
  212. "iftrue": "0",
  213. "iftrueVal": "",
  214. "iffalse": "2",
  215. "iffalseVal": "21",
  216. "name": "Check Variable"
  217. },
  218. {
  219. "storage": "1",
  220. "varName": "maxLoopCAP",
  221. "changeType": "0",
  222. "value": "0",
  223. "name": "Control Variable"
  224. },
  225. {
  226. "behavior": "1",
  227. "interpretation": "0",
  228. "code": "msg.author.lastMessage.delete()\nvar timeResult = tempVars('giveawayTime').content\ntimeResult = timeResult.toLowerCase()\nvar Discord = require('discord.js')\nvar giveawayPrompt = tempVars('giveawayPrompt')\n\nif (timeResult.includes('d')) {\n timeResult = timeResult.split('d')\n if (!isNaN(timeResult[0])) {\n var time = parseInt(timeResult[0])\n this.storeValue(time * 1440, 1, 'giveawayTime', cache)\n var currentDate = new Date()\n currentDate.setHours(currentDate.getHours(), currentDate.getMinutes() + time * 1440)\n currentDate = currentDate.toLocaleString('en-US', { timeZone: 'UTC', hour12: true })\n var currentDateTime = currentDate.split(',')[1]\n var currentDateDate = currentDate.split(',')[0]\n var newEmbed = new Discord.RichEmbed({\n color: 0x2E7F98,\n author: {\n name: 'πŸŽ‰ New Giveaway πŸŽ‰',\n icon_url: (client || this.getDBM().Bot.bot).user.avatarURL\n },\n description: 'New giveaway for **' + tempVars('giveawayObject').content + '**\\n React with πŸŽ‰ to enter the giveaway!',\n footer: {\n text: 'The giveaway will end at ' + currentDateDate + ' on ' + currentDateTime + ' UTC | ' + tempVars('numberOfMembers').toString() + ' Winners'\n }\n })\n this.storeValue(newEmbed, 1, 'giveawayMessage', cache)\n this.callNextAction(cache)\n } else {\n msg.channel.send({\n embed: {\n color: 0xff6666,\n author: {\n name: 'Error - Invalid Time',\n icon_url: (client || this.getDBM().Bot.bot).user.avatarURL\n },\n description: 'You have entered a invalid time, please activate the command again to retry \\n \\n The format to respond with is [time][d,h,m] \\n Some example responses are 12d or 3h or 4m'\n }\n })\n giveawayPrompt.delete()\n }\n} else if (timeResult.includes('h')) {\n timeResult = timeResult.split('h')\n if (!isNaN(timeResult[0])) {\n var time = parseInt(timeResult[0])\n this.storeValue(time * 60, 1, 'giveawayTime', cache)\n var currentDate = new Date()\n currentDate.setHours(currentDate.getHours(), currentDate.getMinutes() + time * 60)\n currentDate = currentDate.toLocaleString('en-US', { timeZone: 'UTC', hour12: true })\n var currentDateTime = currentDate.split(',')[1]\n var currentDateDate = currentDate.split(',')[0]\n var newEmbed = new Discord.RichEmbed({\n color: 0x2E7F98,\n author: {\n name: 'πŸŽ‰ New Giveaway πŸŽ‰',\n icon_url: (client || this.getDBM().Bot.bot).user.avatarURL\n },\n description: 'New giveaway for **' + tempVars('giveawayObject').content + '**\\n React with πŸŽ‰ to enter the giveaway!',\n footer: {\n text: 'The giveaway will end at ' + currentDateDate + ' on ' + currentDateTime + ' UTC | ' + tempVars('numberOfMembers').toString() + ' Winners'\n }\n })\n this.storeValue(newEmbed, 1, 'giveawayMessage', cache)\n this.callNextAction(cache)\n } else {\n msg.channel.send({\n embed: {\n color: 0xff6666,\n author: {\n name: 'Error - Invalid Time',\n icon_url: (client || this.getDBM().Bot.bot).user.avatarURL\n },\n description: 'You have entered a invalid time, please activate the command again to retry \\n \\n The format to respond with is [time][d,h,m] \\n Some example responses are 12d or 3h or 4m'\n }\n })\n giveawayPrompt.delete()\n }\n} else if (timeResult.includes('m')) {\n timeResult = timeResult.split('m')\n if (!isNaN(timeResult[0])) {\n var time = parseInt(timeResult[0])\n this.storeValue(time, 1, 'giveawayTime', cache)\n var currentDate = new Date()\n currentDate.setHours(currentDate.getHours(), currentDate.getMinutes() + time)\n currentDate = currentDate.toLocaleString('en-US', { timeZone: 'UTC', hour12: true })\n var currentDateTime = currentDate.split(',')[1]\n var currentDateDate = currentDate.split(',')[0]\n var newEmbed = new Discord.RichEmbed({\n color: 0x2E7F98,\n author: {\n name: 'πŸŽ‰ New Giveaway πŸŽ‰',\n icon_url: (client || this.getDBM().Bot.bot).user.avatarURL\n },\n description: 'New giveaway for **' + tempVars('giveawayObject').content + '**\\n React with πŸŽ‰ to enter the giveaway!',\n footer: {\n text: 'The giveaway will end at ' + currentDateDate + ' on ' + currentDateTime + ' UTC | ' + tempVars('numberOfMembers').toString() + ' Winners'\n }\n })\n this.storeValue(newEmbed, 1, 'giveawayMessage', cache)\n this.callNextAction(cache)\n } else {\n msg.channel.send({\n embed: {\n color: 0xff6666,\n author: {\n name: 'Error - Invalid Time',\n icon_url: (client || this.getDBM().Bot.bot).user.avatarURL\n },\n description: 'You have entered a invalid time, please activate the command again to retry \\n \\n The format to respond with is [time][d,h,m] \\n Some example responses are 12d or 3h or 4m'\n }\n })\n giveawayPrompt.delete()\n }\n} else {\n msg.channel.send({\n embed: {\n color: 0xff6666,\n author: {\n name: 'Error - Invalid Time',\n icon_url: (client || this.getDBM().Bot.bot).user.avatarURL\n },\n description: 'You have entered a invalid time, please activate the command again to retry \\n \\n The format to respond with is [time][d,h,m] \\n Some example responses are 12d or 3h or 4m'\n }\n })\n}\n",
  229. "storage": "0",
  230. "varName": "",
  231. "name": "Run Script"
  232. },
  233. {
  234. "storage": "1",
  235. "varName": "giveawayPrompt",
  236. "message": "What channel would you like this giveaway to be posted in?\n\nPlease respond by mentioning a channel\n#[channelname]\n\nEx. My channel name I want the giveaway to be hosted in is giveaways\nI would respond with\n#giveaways",
  237. "name": "Edit Message"
  238. },
  239. {
  240. "storage": "1",
  241. "varName": "maxLoopCAP",
  242. "changeType": "1",
  243. "value": "1",
  244. "name": "Control Variable"
  245. },
  246. {
  247. "storage": "0",
  248. "varName": "",
  249. "filter": "content",
  250. "max": "1",
  251. "time": "20000",
  252. "storage2": "1",
  253. "varName2": "channelGiven",
  254. "iftrue": "0",
  255. "iftrueVal": "",
  256. "iffalse": "2",
  257. "iffalseVal": "21",
  258. "name": "Await Response Call Action"
  259. },
  260. {
  261. "message": "1",
  262. "varName": "channelGiven",
  263. "info": "3",
  264. "storage": "1",
  265. "varName2": "responseAuthor",
  266. "name": "Store Message Info"
  267. },
  268. {
  269. "storage": "1",
  270. "varName": "maxLoopCAP",
  271. "comparison": "4",
  272. "value": "20",
  273. "iftrue": "2",
  274. "iftrueVal": "41",
  275. "iffalse": "0",
  276. "iffalseVal": "3",
  277. "name": "Check Variable"
  278. },
  279. {
  280. "storage": "1",
  281. "varName": "msgAuthor",
  282. "comparison": "1",
  283. "value": "tempVars(\"responseAuthor\")",
  284. "iftrue": "0",
  285. "iftrueVal": "",
  286. "iffalse": "2",
  287. "iffalseVal": "29",
  288. "name": "Check Variable"
  289. },
  290. {
  291. "storage": "1",
  292. "varName": "maxLoopCAP",
  293. "changeType": "0",
  294. "value": "0",
  295. "name": "Control Variable"
  296. },
  297. {
  298. "behavior": "1",
  299. "interpretation": "0",
  300. "code": "var channelMentioned = ''\nvar embedMessageStored = tempVars('giveawayMessage')\nvar _this = this\nvar giveawayPrompt = tempVars('giveawayPrompt')\n\nif (msg.author.lastMessage.mentions.channels.first()) {\n var giveawayChannel = msg.author.lastMessage.mentions.channels.first()\n _this.storeValue(giveawayChannel, 1, 'giveawayChannel', cache)\n giveawayChannel.send(embedMessageStored)\n .then(function (message) {\n message.react('πŸŽ‰')\n _this.storeValue(message, 1, 'giveawayMessageSent', cache)\n }).catch(function (error) {\n console.log(error)\n })\n embedMessageStored.color = 0x000000\n _this.storeValue(embedMessageStored, 1, 'giveawayMessage', cache)\n _this.callNextAction(cache)\n} else {\n msg.channel.send({\n embed: {\n color: 0xff6666,\n author: {\n name: 'Error - Invalid Channel',\n icon_url: msg.mentions.users.first().avatarURL\n },\n description: 'You have entered a invalid channel, please activate the command again to retry \\n \\n The format to respond with is #[channel] \\n Some example responses are #giveaways or #general or #annoucements'\n }\n })\n giveawayPrompt.delete()\n}\nmsg.author.lastMessage.delete()",
  301. "storage": "0",
  302. "varName": "",
  303. "name": "Run Script"
  304. },
  305. {
  306. "storage": "1",
  307. "varName": "giveawayPrompt",
  308. "name": "Delete Message"
  309. },
  310. {
  311. "storage": "0",
  312. "varName": "giveawayPrompt",
  313. "name": "Delete Message"
  314. },
  315. {
  316. "time": "${tempVars(\"giveawayTime\")}",
  317. "measurement": "2",
  318. "name": "Wait"
  319. },
  320. {
  321. "behavior": "1",
  322. "interpretation": "0",
  323. "code": "async function getReactions () {\n try {\n var giveawayMsg = tempVars('giveawayMessageSent');\n var giveawayEmbed = tempVars('giveawayMessage');\n var numberOfMembers = tempVars('numberOfMembers');\n var winnerArray = [];\n var winnerText = '';\n var users = await giveawayMsg.reactions.get('πŸŽ‰').fetchUsers()\n var userArray = users.array();\n \n if (userArray.length > 1) {\n userArray = userArray.filter(function(item) { \n return item.id !== client.user.id\n })\n if (userArray.length >= numberOfMembers) {\n for (var i = 0; i < numberOfMembers; i++) {\n if (userArray[i].id != client.user.id) {\n var randomNumber = Math.floor(Math.random() * userArray.length);\n var randomuser = await userArray[randomNumber];\n winnerArray.push(randomuser);\n userArray.splice(userArray.indexOf(randomNumber), randomNumber);\n }\n }\n for (i = 0; i < winnerArray.length; i++) {\n winnerText = winnerText + winnerArray[i] + '\\n'\n }\n giveawayEmbed.author.name = 'πŸŽ‰ Giveaway Ended πŸŽ‰';\n giveawayEmbed.description = giveawayEmbed.description + '\\n \\n Winners: \\n' + winnerText\n giveawayEmbed.footer.text = giveawayEmbed.footer.text.replace('will end', 'ended');\n giveawayMsg.edit(giveawayEmbed)\n giveawayMsg.channel.send('πŸŽ‰ Congratulations! πŸŽ‰ \\n' + winnerText + 'They have won **' + tempVars('giveawayObject').content + '**');\n } else {\n for (i = 0; i < userArray.length - 1; i++) {\n if (userArray[i].id != client.user.id) {\n var randomNumber = Math.floor(Math.random() * userArray.length);\n var randomuser = await userArray[randomNumber];\n winnerArray.push(randomuser)\n userArray.splice(userArray.indexOf(randomNumber) , randomNumber);\n }\n }\n for (i = 0; i < winnerArray.length; i++) {\n winnerText = winnerText + winnerArray[i] + '\\n';\n }\n giveawayEmbed.author.name = 'πŸŽ‰ Giveaway Ended πŸŽ‰'\n giveawayEmbed.description = giveawayEmbed.description + '\\n \\n Winners: \\n' + winnerText\n giveawayMsg.edit(giveawayEmbed)\n giveawayMsg.channel.send('πŸŽ‰ Congratulations! πŸŽ‰ \\n' + winnerText + '\\nThey have won **' + tempVars('giveawayObject').content + '**\\n \\nNote:The number of people who reacted isn\\'t enough to satisfy the numbers of members that can win so the bot has gotten the maximum number of people it can draw to win.')\n }\n } else {\n msg.channel.send({\n embed: {\n color: 0xff6666,\n author: {\n name: 'No one reacted',\n icon_url: (client || this.getDBM().Bot.bot).user.avatarURL\n },\n description: 'None has reacted so no one won. Oh well'\n }\n })\n }\n } catch (error) {\n msg.channel.send({\n embed: {\n color: 0xff6666,\n author: {\n name: 'Error - Giveaway Error',\n icon_url: (client || this.getDBM().Bot.bot).user.avatarURL\n },\n description: 'Please retry the command, the bot has errored \\n This may be due to the fact that it may of not been able to grab the reactions \\n An error message has been outputted to console for futher debugging'\n }\n })\n console.log('Giveaway Command Error: ' + error)\n }\n}\ngetReactions()\n",
  324. "storage": "0",
  325. "varName": "",
  326. "name": "Run Script"
  327. },
  328. {
  329. "name": "End Action Sequence"
  330. },
  331. {
  332. "title": "Giveaway Creation - Timeout",
  333. "author": "",
  334. "color": "ff6666",
  335. "timestamp": "true",
  336. "url": "",
  337. "authorIcon": "",
  338. "imageUrl": "",
  339. "thumbUrl": "",
  340. "storage": "1",
  341. "varName": "embed",
  342. "name": "Create Embed Message"
  343. },
  344. {
  345. "storage": "1",
  346. "varName": "embed",
  347. "message": "The command has timeout as you either took too long or too many people has chatted while you are trying to setup the giveaway\n\nPlease try again, in an less active channel so you can see the original message that gives you instructions on how to setup the giveaway",
  348. "name": "Set Embed Description"
  349. },
  350. {
  351. "storage": "1",
  352. "varName": "embed",
  353. "channel": "0",
  354. "varName2": "",
  355. "storage3": "0",
  356. "varName3": "",
  357. "name": "Send Embed Message"
  358. },
  359. {
  360. "name": "End Action Sequence"
  361. },
  362. {
  363. "title": "Giveaway Creation - No Permission",
  364. "author": "",
  365. "color": "ff6666",
  366. "timestamp": "true",
  367. "url": "",
  368. "authorIcon": "",
  369. "imageUrl": "",
  370. "thumbUrl": "",
  371. "storage": "1",
  372. "varName": "embed",
  373. "name": "Create Embed Message"
  374. },
  375. {
  376. "storage": "1",
  377. "varName": "embed",
  378. "message": "You do not have permission to start a giveaway!\nYou need the permission `Manage Messages`",
  379. "name": "Set Embed Description"
  380. },
  381. {
  382. "storage": "1",
  383. "varName": "embed",
  384. "channel": "0",
  385. "varName2": "",
  386. "storage3": "0",
  387. "varName3": "",
  388. "name": "Send Embed Message"
  389. }
  390. ]
  391. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement