import fs from "fs";
import { MongoClient } from "mongodb";

const mongoClient = new MongoClient("mongodb://127.0.0.1:27017/local");
await mongoClient.connect();
const database = mongoClient.db("Nucleus");
const collection = database.collection("migrationTesting");

// Loop through all files in the oldData folder
const files = fs.readdirSync("./oldData");
let x = 0;
for (const file of files) {
    console.log(`┌ Processing file ${x} of ${files.length - 1} | ${file}`);
    // Read the file as a json
    let data;
    try {
        data = JSON.parse(fs.readFileSync(`./oldData/${file}`));
    } catch {
        console.log(`└ Error reading file ${file}`);
        x++;
        continue;
    }
    // Check if data version is 3
    if (data.version !== 3) {
        console.log(`├ Version was too old on ${file}`);
        console.log("└ Skipping file");
        x++;
        continue;
    }
    // Convert to the new format
    const newData = {
        id: data.guild_info.id.toString(),
        version: 1,
        singleEventNotifications: {
            statsChannelDeleted: false
        },
        filters: {
            images: {
                NSFW: !data.images.nsfw,
                size: data.images.toosmall
            },
            wordFilter: {
                enabled: true,
                words: {
                    strict: data.wordfilter.strict,
                    loose: data.wordfilter.soft
                }
            },
            invite: {
                enabled: data.invite ? data.invite.enabled : false,
                channels: data.invite
                    ? data.invite.whitelist.channels.map((channel) =>
                          channel.toString()
                      )
                    : []
            },
            pings: {
                mass: 5,
                everyone: true,
                roles: true
            }
        },
        welcome: {
            enabled: data.welcome ? data.welcome.message.text !== null : false,
            verificationRequired: {
                message: null,
                role: null
            },
            role: data.welcome
                ? data.welcome.role !== null
                    ? data.welcome.role.toString()
                    : null
                : null,
            channel: data.welcome
                ? data.welcome.message.text !== null
                    ? data.welcome.message.channel.toString()
                    : null
                : null,
            message: data.welcome ? data.welcome.message.text : null
        },
        stats: {},
        logging: {
            logs: {
                enabled: true,
                channel: data.log_info.log_channel
                    ? data.log_info.log_channel.toString()
                    : null,
                toLog: "3fffff"
            },
            staff: {
                channel: data.log_info.staff
                    ? data.log_info.staff.toString()
                    : null
            }
        },
        verify: {
            enabled: data.verify_role !== null,
            role: data.verify_role ? data.verify_role.toString() : null
        },
        tickets: {
            enabled: data.modmail ? data.modmail.cat !== null : null,
            category: data.modmail
                ? data.modmail.cat !== null
                    ? data.modmail.cat.toString()
                    : null
                : null,
            types: "3f",
            customTypes: null,
            supportRole: data.modmail
                ? data.modmail.mention !== null
                    ? data.modmail.mention.toString()
                    : null
                : null,
            maxTickets: data.modmail ? data.modmail.max : 5
        },
        moderation: {
            mute: {
                timeout: true,
                role: null,
                text: null,
                link: null
            },
            kick: {
                text: null,
                link: null
            },
            ban: {
                text: null,
                link: null
            },
            softban: {
                text: null,
                link: null
            },
            warn: {
                text: null,
                link: null
            },
            role: {
                role: null
            }
        },
        tracks: [],
        roleMenu: [],
        tags: data.tags
    };
    // Insert the new data into the database
    await collection.updateOne(
        { id: data.guild_info.id.toString() },
        { $set: newData },
        { upsert: true }
    );
    // Delete the old file
    fs.unlinkSync(`./oldData/${file}`);
    console.log(`└ Successfully migrated file ${file}`);
    x++;
}

// console.log((await collection.findOne({ id: "your mother" })));
