Created
December 8, 2020 20:49
-
-
Save 3h50/2a998404a0575378b23d0b741087954b to your computer and use it in GitHub Desktop.
Slackord 2 Node.JS Channel JSON Joiner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var dirname = __dirname + "\\json\\"; | |
outputFile = "bulk.json"; | |
let output = []; | |
function readFiles() { | |
let filenames = fs.readdirSync(dirname); | |
filenames.forEach((filename)=> { | |
fileloc = dirname + filename; | |
onFileContent(fs.readFileSync(fileloc)); | |
}); | |
} | |
function onFileContent(content) { | |
let fileObject = JSON.parse(content); | |
fileObject.forEach((message) => { | |
output.push(message); | |
}) | |
} | |
function saveJson() { | |
fs.writeFileSync(`./${outputFile}`, JSON.stringify(output), err => { | |
if (err) { | |
console.log('Error writing file', err) | |
} else { | |
console.log('Successfully wrote file') | |
} | |
}) | |
} | |
readFiles(); | |
saveJson(); | |
// console.log(`FINAL OUTPUT: ${JSON.stringify(output)}`);1 |
Its possibly doable but at that point I'd also probably just use this as the transporter to discord. Its already reading the files into an object. I havent looked at the discord documentation though, im not aure of bots can move channels on their own they arent invited to. Youd also need to make sure channel names were created that matched but only if a bot cant create them.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you make this switch directories for each channel and do a bulk.json for each?