Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = {
- name: 'array',
- description: "very useful and well written module that does important things",
- execute(message, args) {
- const fs = require('fs')
- let text = fs.readFileSync("toarray").toString('utf-8')
- let array = text.slice(text.indexOf(".") + 3).split("\n")
- let XD = text.slice(0, text.indexOf("\n")).split(" ")
- let DX = [text.slice(text.indexOf("\n") + 1, text.indexOf(".") + 1)]
- let print = ""
- let d = 0
- let a = 0
- let b = 2
- let c = false
- const noop = () => { };
- const die = {
- "1R": "1 Round",
- "2R": "2 Rounds"
- }
- let merc = "Alec"
- let max = 15
- let obj = {}
- obj[`${merc}`] = {}
- obj[`${merc}`]["1"] = {
- "title": "",
- "thumbnail": "",
- "effects": "",
- "details": "",
- }
- obj[`${merc}`]["1"]["title"] += merc + ": +" + max + " "
- for (let i = 2; i < XD.length; i++) {
- obj[`${merc}`]["1"]["title"] += XD[i]
- if (XD.length - i != 1) obj[`${merc}`]["1"]["title"] += " "
- }
- obj[`${merc}`]["1"]["details"] = [die[XD[0]], "**Target:** " + XD[1]]
- obj[`${merc}`]["1"]["effects"] = DX
- for (let i = 0; i < array.length; i++) {
- if (d === 0 && a === 0)
- obj[`${merc}`][`${b}`] = {
- "title": "",
- "thumbnail": "",
- "effects": "",
- "details": "",
- "exceptions": ""
- }
- if (array[i] === "" && d === 5) {
- obj[`${merc}`][`${b}`].exceptions = print.split(",")
- c = true
- print = ""
- }
- if (array[i] === "") {
- if (obj[`${merc}`][`${b}`]["exceptions"] === "")
- delete obj[`${merc}`][`${b}`]["exceptions"]
- d = 0
- a = -1
- console.log(print.split(","))
- if (c === false)
- obj[`${merc}`][`${b}`].effects = print.split(",")
- c = false
- b++
- print = ""
- }
- else if (array[i] != "" && d === 0 && a === 0) {
- print += array[i]
- obj[`${merc}`][`${b}`].title = print
- print = ""
- }
- else if (array[i] != "" && d === 0 && a < 5) {
- print += array[i]
- d = 1
- }
- else if (array[i] != "" && a < 5) {
- print += "," + array[i]
- }
- else if (array[i] != "" && a === 5) {
- d = 2
- obj[`${merc}`][`${b}`].details = print.split(",")
- print = ""
- }
- if (array[i] === "Exception") {
- if (c === false)
- obj[`${merc}`][`${b}`].effects = print.split(",")
- print = ""
- d = 4
- }
- else if (array[i] != "Exception" && d === 2) {
- print += array[i]
- d = 3
- }
- else if (array[i] != "Exception" && d === 3) {
- print += "," + array[i]
- }
- else if (array[i] != "Exception" && d === 4) {
- print += array[i]
- d = 5
- }
- else if (d === 5) {
- print += "," + array[i] + ""
- }
- a++
- }
- let json = JSON.stringify(obj)
- console.log(obj)
- fs.writeFile("arraytest.json", json, "utf8", noop)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement