Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. module.exports = {
  2. name: 'array',
  3. description: "very useful and well written module that does important things",
  4. execute(message, args) {
  5. const fs = require('fs')
  6. let text = fs.readFileSync("toarray").toString('utf-8')
  7. let array = text.slice(text.indexOf(".") + 3).split("\n")
  8. let XD = text.slice(0, text.indexOf("\n")).split(" ")
  9. let DX = [text.slice(text.indexOf("\n") + 1, text.indexOf(".") + 1)]
  10. let print = ""
  11. let d = 0
  12. let a = 0
  13. let b = 2
  14. let c = false
  15. const noop = () => { };
  16. const die = {
  17. "1R": "1 Round",
  18. "2R": "2 Rounds"
  19. }
  20.  
  21. let merc = "Alec"
  22. let max = 15
  23. let obj = {}
  24.  
  25. obj[`${merc}`] = {}
  26. obj[`${merc}`]["1"] = {
  27. "title": "",
  28. "thumbnail": "",
  29. "effects": "",
  30. "details": "",
  31. }
  32. obj[`${merc}`]["1"]["title"] += merc + ": +" + max + " "
  33. for (let i = 2; i < XD.length; i++) {
  34. obj[`${merc}`]["1"]["title"] += XD[i]
  35. if (XD.length - i != 1) obj[`${merc}`]["1"]["title"] += " "
  36. }
  37. obj[`${merc}`]["1"]["details"] = [die[XD[0]], "**Target:** " + XD[1]]
  38. obj[`${merc}`]["1"]["effects"] = DX
  39.  
  40. for (let i = 0; i < array.length; i++) {
  41. if (d === 0 && a === 0)
  42. obj[`${merc}`][`${b}`] = {
  43. "title": "",
  44. "thumbnail": "",
  45. "effects": "",
  46. "details": "",
  47. "exceptions": ""
  48. }
  49.  
  50. if (array[i] === "" && d === 5) {
  51. obj[`${merc}`][`${b}`].exceptions = print.split(",")
  52. c = true
  53. print = ""
  54. }
  55.  
  56. if (array[i] === "") {
  57. if (obj[`${merc}`][`${b}`]["exceptions"] === "")
  58. delete obj[`${merc}`][`${b}`]["exceptions"]
  59. d = 0
  60. a = -1
  61. console.log(print.split(","))
  62. if (c === false)
  63. obj[`${merc}`][`${b}`].effects = print.split(",")
  64. c = false
  65. b++
  66. print = ""
  67. }
  68. else if (array[i] != "" && d === 0 && a === 0) {
  69. print += array[i]
  70. obj[`${merc}`][`${b}`].title = print
  71. print = ""
  72. }
  73. else if (array[i] != "" && d === 0 && a < 5) {
  74. print += array[i]
  75. d = 1
  76. }
  77. else if (array[i] != "" && a < 5) {
  78. print += "," + array[i]
  79. }
  80. else if (array[i] != "" && a === 5) {
  81. d = 2
  82. obj[`${merc}`][`${b}`].details = print.split(",")
  83. print = ""
  84. }
  85.  
  86. if (array[i] === "Exception") {
  87. if (c === false)
  88. obj[`${merc}`][`${b}`].effects = print.split(",")
  89. print = ""
  90. d = 4
  91. }
  92. else if (array[i] != "Exception" && d === 2) {
  93. print += array[i]
  94. d = 3
  95. }
  96. else if (array[i] != "Exception" && d === 3) {
  97. print += "," + array[i]
  98. }
  99. else if (array[i] != "Exception" && d === 4) {
  100. print += array[i]
  101. d = 5
  102. }
  103. else if (d === 5) {
  104. print += "," + array[i] + ""
  105. }
  106. a++
  107. }
  108.  
  109. let json = JSON.stringify(obj)
  110. console.log(obj)
  111.  
  112. fs.writeFile("arraytest.json", json, "utf8", noop)
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement