2017-12-11 03:05:18 +02:00
|
|
|
// @ts-nocheck
|
2017-12-08 02:54:07 +02:00
|
|
|
const NewGuildData = require("./models/guild-data.js");
|
|
|
|
const NewFeedData = require("./models/feed-data.js");
|
|
|
|
const FileSystem = require("fs");
|
|
|
|
|
|
|
|
module.exports = function () {
|
2018-01-27 01:47:23 +02:00
|
|
|
if (!FileSystem.existsSync("./guilds.json"))
|
|
|
|
return;
|
2017-12-08 02:54:07 +02:00
|
|
|
|
2018-01-27 01:47:23 +02:00
|
|
|
const legacyJson = require("../guilds.json");
|
2017-12-08 02:54:07 +02:00
|
|
|
|
2018-01-27 01:47:23 +02:00
|
|
|
for (let guildID of Object.keys(legacyJson)) {
|
|
|
|
const guildData = NewGuildData.create({ guildID });
|
2017-12-08 02:54:07 +02:00
|
|
|
|
2018-01-27 01:47:23 +02:00
|
|
|
for (let feed of legacyJson[guildID].feeds) {
|
|
|
|
guildData.feeds.push(NewFeedData.create({
|
|
|
|
feedID: feed.id,
|
|
|
|
url: feed.url,
|
|
|
|
roleID: feed.roleID,
|
|
|
|
channelID: feed.channelID,
|
|
|
|
cachedLinks: feed.cachedLinks,
|
|
|
|
maxCacheSize: feed.maxCacheSize
|
|
|
|
}));
|
|
|
|
}
|
2017-12-08 02:54:07 +02:00
|
|
|
|
2018-01-27 01:47:23 +02:00
|
|
|
guildData.save();
|
|
|
|
}
|
2017-12-08 02:54:07 +02:00
|
|
|
|
2018-01-27 01:47:23 +02:00
|
|
|
FileSystem.rename("./guilds.json", "./guilds.json.backup");
|
2017-12-08 02:54:07 +02:00
|
|
|
};
|